Jacek Sieka
b4aff8fec5
remove `news` support ( #155 )
...
`news` has several resource leaks and other security issues - replaced
by `nim-websock` which is actively maintained.
2022-11-08 14:39:29 +01:00
Jacek Sieka
e6810af618
expose http server options ( #154 )
...
* expose http server options
These are needed to create a server that can handle larger POST requests
* add socket flag options
2022-10-25 18:48:44 +02:00
KonradStaniec
64dbf122d7
Add authhooks to proxy constructor ( #153 )
2022-09-22 10:58:19 +02:00
Jacek Sieka
5fa7071d5b
use `object` fromJson after creating `ref object` instance
...
otherwise, Option fields don't work as expected
2022-09-21 14:43:41 +02:00
Etan Kissling
446b18819d
do not disable TLS verification by default ( #148 )
...
Setting `NoVerifyHost`, `NoVerifyServerName` by default leads to
hard-to-debug bugs, it should always be explicit if wanted.
Note: This is also a workaround for https://github.com/status-im/nim-chronos/issues/313
2022-09-16 21:38:56 +02:00
Jacek Sieka
7c80b75856
fix enum parsing, work around potential `nil` dereference ( #150 )
...
* fix enum parsing, work around potential `nil` dereference
When the bizarre error handling in the http client fails, it may happen
that a nil is returned (maybe due to Nim bugs) - do it manually for now
2022-09-15 22:32:16 +03:00
Etan Kissling
c8cbe08de7
align `nim-websock` support with `news`
...
To allow switching between `news` and `nim-websock` in `nimbus-eth2`,
add support for the missing CORS and JWT authorization headers to the
`nim-websock` backend. Also transition from `StringTableRef` to
`HttpTable` to properly support multiple instances of same header name.
2022-09-05 22:44:06 +07:00
jangko
5ccdaed0ad
add rng param to rpcWebsocketServer constructor
2022-07-27 09:46:36 +07:00
jangko
0fee4be2cc
implement hook to handle CORS and JWT auth
...
- fixes #138
- fixes #126
- fixes #38
2022-07-17 23:06:08 +07:00
Zahary Karadjov
d618b555e7
Use news by default; websock has known issues
2022-06-28 18:12:51 +03:00
Zahary Karadjov
335f292a58
Fix connection leaks in the HTTP client
2022-04-10 21:48:46 +03:00
Jacek Sieka
2e3d22b9e2
enable `styleCheck:usages` ( #135 )
2022-04-08 10:25:41 +02:00
Jordan Hrycaj
b80313bfed
Facilitate http code response on authentication failure ( #134 )
2022-04-07 08:34:10 +01:00
Jordan Hrycaj
d4ae2328d4
Add server Hook for authentication ( #133 )
...
why:
JWT authentication needs that
2022-04-05 16:19:52 +01:00
Jacek Sieka
b4bab89abd
fix invalid raises annotations ( #132 )
...
* `raises` should not be used with async
* callbacks returning futures should not raise
2022-03-21 15:19:49 +01:00
Dustin Brody
2d0a417844
no-op on nil
2022-03-04 21:07:17 +00:00
Dustin Brody
b455958d8a
request header callback
2022-03-04 19:13:29 +00:00
jangko
ad0c3fb6e0
fix missing req id in router exception handler
...
when an rpc method in server throw `InvalidRequest` using custom error code,
the router need to mention the request id too.
otherwise the client will throw error with confusing message.
2022-02-28 09:39:49 +07:00
tersec
0540afad4c
specify Content-Type: application/json HTTP header ( #129 )
2022-02-23 08:43:08 +01:00
jangko
51fadf850c
Fix #124
2022-02-14 12:16:31 +07:00
Zahary Karadjov
97ba55bbf6
Release the HTTP sessions
2022-02-02 19:51:04 +02:00
Zahary Karadjov
5a28176080
Fix #117
2022-01-08 21:39:29 +02:00
Jacek Sieka
77c85a8876
fix missing logging import
2021-12-17 11:36:49 +01:00
Zahary Karadjov
35e6d7e6ff
Restore the support for using the news package
2021-11-29 15:36:17 +02:00
Zahary Karadjov
7ff4559cc0
Allow dynamic RPC method names in the 'rpc' macro
2021-11-24 15:57:46 +02:00
Zahary Karadjov
c455198d4f
Eliminate code duplication in the HTTP/S servers
2021-11-22 20:24:11 +02:00
Zahary Karadjov
e4dba96f5c
Improve cancellation support and code style
2021-11-22 17:24:07 +02:00
Zahary Karadjov
7ab1b31614
Fix code breakage after the rebase
2021-11-22 17:05:26 +02:00
Bernardo A. Rodrigues
3599a73b58
Chronos HTTP(S) Server ( #111 )
2021-11-22 15:14:30 +02:00
Zahary Karadjov
9db5407e81
Switch to Chronos HTTP client (adds support for HTTPS)
2021-11-22 15:14:27 +02:00
Zahary Karadjov
2307dbec57
Add support for producing custom error codes from request hanlers
2021-10-06 10:50:08 +02:00
jangko
b2417fc071
fix both ws rpc server and client due to websock breaking changes
...
- change recv() to recvMsg()
2021-08-05 14:54:36 +07:00
KonradStaniec
a1715e33ac
Make client config public ( #113 )
2021-08-02 13:18:51 +02:00
KonradStaniec
eda5e8554f
add support for websocket in proxy ( #112 )
2021-07-30 11:24:09 +02:00
jangko
318949a401
fixes ws rpc client bug: error when trying to connect to infura
...
fixes #109
previously, if using uri such as "wss://mainnet.infura.io/ws/v3/infura-id",
the client will throw error. this bug already fixed in nim-websock,
now this also fixed in json-rpc. it works when connected to infura wss.
2021-07-19 10:35:23 +07:00
KonradStaniec
a138c410c5
[FEATURE] Add additional constructor to the proxy ( #108 )
2021-07-12 07:22:01 +02:00
KonradStaniec
147ef3f562
[FEATURE] Add http json rpc proxy ( #105 )
2021-06-29 18:13:31 +03:00
jangko
809172abe4
rename ws to websock
2021-06-29 11:51:05 +07:00
jangko
62becee070
rpcwsserver: allocate deflateFactory only if compression enabled
2021-06-25 16:41:58 +07:00
jangko
b9e9be8f19
use string.fromBytes to replace cast[string](bytes)
2021-06-24 06:52:32 +07:00
jangko
69e8be66fb
add compression support for websocket rpc server-client
...
fixes #62
2021-06-24 06:52:31 +07:00
jangko
b8a8ca2623
replace news with nim-ws
...
fixes #103
2021-06-24 06:52:31 +07:00
jangko
c6be913c69
implement json rpc websocket server
...
- both ws and wss mode
fixes #76
2021-06-23 18:44:33 +07:00
Zahary Karadjov
7a9d118929
More proper client closing code
2021-04-07 00:40:54 +03:00
Jacek Sieka
64d40d6c1a
simplify imports ( #98 )
...
remove broken uint64 converter - upstream std/json also includes a
broken uint64 converter
2021-03-26 13:17:00 +01:00
Jacek Sieka
ac5288651c
Exception handling signatures ( #97 )
...
Minimally work around leaking `Exception` for
https://github.com/status-im/nim-chronos/pull/166
2021-03-26 11:53:03 +01:00
Jacek Sieka
4eb39203eb
fixes ( #95 )
...
* fixes
* fix https://github.com/status-im/nimbus-eth2/issues/1650
* only one of `result` and `error` allowed in response
* fix invalid `string` instances being created from byte sequences
* fix large int64 parsing on 32-bit
* fix exception inheritance
* fix some dangling results
* some cleanups
* annotate exception issues, fix cancellation
* more error handling cleanup
* add rudimentary error tests
* cleanups
* simplify init
* use nextId -> lastId to avoid =1 init
* remove obsolete tests
2021-02-15 13:45:51 +01:00
Joe Clapis
831471f6d4
Added the ability to handle omitted params fields in incoming requests, and a unit test for it ( #94 )
2021-02-07 20:27:34 +01:00
Ștefan Talpalaru
b0e82cb70a
enable cross-compilation
2021-02-03 21:36:08 +02:00
Jacek Sieka
ce51ffdf16
print url in log startup message ( #89 )
...
...and tone down connection logging
2021-01-07 10:42:26 +01:00
Hanno Cornelius
dc3a2d33fc
Added marshalling support for uint32 ( #88 )
...
* Added marshalling support for uint32
* Update json_rpc/jsonmarshal.nim
Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
2020-11-16 15:45:53 +01:00
Mamy Ratsimbazafy
99455437ba
Fix silent uint64 negative conversion https://github.com/status-im/nim-beacon-chain/issues/1671 https://github.com/status-im/nim-beacon-chain/pull/1819 ( #85 )
2020-10-07 12:09:36 +02:00
Giovanni Petrantoni
62349c39c6
avoid spamming logs when rpcs happen ( #83 )
2020-09-05 20:41:26 +02:00
Ștefan Talpalaru
d90bdb679b
can't use `result` when returning Future[void]
2020-08-07 17:24:15 +02:00
Zahary Karadjov
244254632b
Improved handling of invalid responses; Handle seq[byte] results such as `eth_getCode`
2020-06-19 20:42:49 +03:00
Viktor Kirilov
8c1a8ef8d9
serialization for tuples - just like for objects
2020-06-11 14:56:57 +03:00
Viktor Kirilov
271512c161
proper name for topics so that we can filter dynamically using chronicles
2020-06-09 17:00:21 +03:00
Viktor Kirilov
ecf49a0632
updated news
2020-05-08 16:13:00 +03:00
Zahary Karadjov
5c0d096111
Support Nim 1.2
2020-03-24 16:50:34 +02:00
Zahary Karadjov
6fbaeb61ca
Switch to json_serialition.JsonString to facilitate Chronicles logging
2020-03-18 18:14:29 +02:00
Zahary Karadjov
f53e0b960b
Fix all tests
2020-03-17 22:05:42 +02:00
Zahary Karadjov
d19de19128
Refactor the router to allow bypassing the use of std/json
...
The users will be now able to write RPC handlers returning the
distinct type `StringOfJson`. This will bypass any use of the
standard library's JsonNode type and its serialization routines.
The change was motivated by the integration of JSON-RPC in
status-im/nim-beacon-chain where most of the data types cannot
be handled by Nim's std lib or json-rpc's jsonmarshal module.
2020-03-17 20:38:52 +02:00
Zahary Karadjov
4d1d2577e9
Trivial changes required for the beacon node integration
2020-03-17 00:17:10 +02:00
Ștefan Talpalaru
09f6fd6355
fix logging in JSON format
2020-02-13 17:05:55 +01:00
Zahary Karadjov
9b401994a1
Follow the convention of naming types as UpperCase
2020-01-21 18:50:50 +02:00
Zahary Karadjov
6f9da4ba8a
Make the RPC procs async again
2020-01-21 18:49:52 +02:00
Ștefan Talpalaru
72a99cc977
replace getCurrentExceptionMsg() and delete some unused imports
2019-12-02 12:26:09 +01:00
Yuriy Glukhov
d4fbed75c7
Better error handling
2019-11-22 15:14:16 +02:00
Yuriy Glukhov
ef2e3cea19
Log errors in websocket readloop
2019-10-11 19:01:11 +09:00
Yuriy Glukhov
07e82fa194
Allow creating http client from url
2019-07-31 12:38:17 +03:00
Ștefan Talpalaru
de05184c74
replace {.gcsafe.} block with more proc pragmas
2019-07-19 13:48:26 +03:00
Ștefan Talpalaru
8168fcea25
fix some problems raised by Nim 0.20.2
2019-07-19 13:48:26 +03:00
Yuriy Glukhov
881c62ed54
Allow custom headers in ws backend. Set Origin to http://localhost by default
2019-07-02 16:15:41 +03:00
Yuriy Glukhov
d031ab3eb4
Fixed error reporting for unexpected response id
2019-06-26 13:40:44 +03:00
Yuriy Glukhov
4bb08c671b
Fixed race condition when rpc server responds too fast
2019-06-26 13:39:58 +03:00
Zahary Karadjov
48699c50ca
Make the new methods gcsafe to solve build issues in Nimbus
2019-06-24 19:49:31 +03:00
Zahary Karadjov
9d0326aad4
Allow building with chronicles_sinks=json
2019-06-20 18:57:13 +03:00
Yuriy Glukhov
b583dfb029
Use closeWait
2019-06-17 19:56:19 +03:00
Yuriy Glukhov
ac2f6b9360
Comments addressed
2019-06-17 18:47:11 +03:00
Yuriy Glukhov
f19d66b35c
Websocket client support and some fixes
2019-06-12 20:53:15 +03:00
kdeme
707567c7ab
Check if method field is a string
2019-05-17 11:58:51 +03:00
cheatfate
a56ad7dfcb
Fix freezes on *nix systems.
2019-05-14 18:42:51 +03:00
kdeme
40411aef5a
Add JObject check to resolve possible unhandled exception
2019-04-29 22:04:56 +03:00
Ștefan Talpalaru
92a7b78f4a
Nim HEAD support
2019-04-26 00:17:04 +02:00
cheatfate
2d3db88137
Fix deprecated warnings.
2019-03-25 19:28:31 +02:00
Ștefan Talpalaru
159f9b816e
assert() -> doAssert()
2019-03-13 22:42:07 +01:00
Mamy Ratsimbazafy
53ed44dfa5
Rebrand asyncdispatch2 to chronos ( #50 )
2019-02-06 18:27:58 +01:00
Ștefan Talpalaru
1083b2972a
support Content-Type headers with specified charset
...
and add RPC message content to the debugging output (at the TRACE level,
disabled by default)
2019-01-28 12:39:27 +02:00
Ștefan Talpalaru
64a9999ac9
another {.gcsafe.} pragma, just for Windows
2019-01-17 18:35:15 +02:00
andri lim
0cdeb04a12
fix httpclient logScope 'topic' to 'topics'
2019-01-16 13:03:57 +02:00
andri lim
b9286104e7
use HTTP1.0 and drop connection:keep-alive
2019-01-12 16:17:19 +02:00
Ștefan Talpalaru
cbbdc34399
fix breakage with Nim HEAD
2019-01-04 15:57:52 +02:00
Yuriy Glukhov
839cc3ae33
Fixed compilation error with newer nim
2018-12-20 12:58:42 +02:00
cheatfate
6a0b0ff30d
Fix support of `Content-Length` response header.
2018-12-10 13:56:10 +02:00
coffeepots
798e86112c
Cover optional cases within objects
2018-11-26 18:03:56 +00:00
coffeepots
51ed6f3000
Remove expectType for Option[T], use fromJson on subtype for validation
2018-11-23 16:10:35 +00:00
coffeepots
e942357de6
Fix iterating through return type
2018-11-23 16:05:46 +00:00
coffeepots
5e7f2d6a61
Merge pull request #42 from jangko/rpc_macro
...
add optional arg support to rpc macro
2018-11-19 10:58:38 +00:00
andri lim
a1fe7d57b4
allow optional parameters in the middle of parameters list
2018-11-16 20:07:39 +07:00
coffeepots
a14e2dbcbb
Merge pull request #41 from jangko/add_http_method
...
fixes #37 add http method get/set to httpclient
2018-11-14 16:48:30 +00:00