summary refs log tree commit diff stats
path: root/lib/pure/net.nim
Commit message (Collapse)AuthorAgeFilesLines
* Revert "net: don't clear all errors on close"Leorize2020-06-061-0/+1
| | | | | | | You're supposed to clear the error queue before any I/O operations. Per SSL_get_error(3) man page. This reverts commit ee3ed37300743addb1344e39bc46d3cd2b89a718.
* net: don't clear all errors on closeLeorize2020-06-061-1/+0
| | | | | | | Closing a socket clears the error queue of the entire thread, which seems to be a bit too invasive. Also I don't find any reason in the PR that added this.
* asyncnet, net: call SSL_shutdown only when connection establishedLeorize2020-06-061-9/+13
| | | | | | This commit prevents "SSL_shutdown while in init" errors from happening. See https://github.com/openssl/openssl/issues/710#issuecomment-253897666
* net: remove more erroneous set constructions (#14252) [backport]alaviss2020-05-071-3/+8
| | | Refs #13764
* Fixes net.recvFrom to work correctly with IPv6 (#14131)rockcavera2020-05-041-10/+22
| | | | | | | * added high level sendTo and recvFrom to std/asyncnet; tests were also added. * add .since annotation, a changelog entry and fixed to standard library style guide. * fixes net.recvFrom to work correctly with IPv6 * raise if domain is not AF_INET or AF_INET6 * renamed template to adaptRecvFromToDomain()
* move since from inclrtl to std/private/since (#14188)hlaaftana2020-05-021-1/+1
| | | | * move since from inclrtl to std/private/since * move since import in system below for HCR
* Error -> Defect for defects (#13908)Jacek Sieka2020-04-281-2/+2
| | | | | | | | | | | | | | * Error -> Defect for defects The distinction between Error and Defect is subjective, context-dependent and somewhat arbitrary, so when looking at an exception, it's hard to guess what it is - this happens often when looking at a `raises` list _without_ opening the corresponding definition and digging through layers of inheritance. With the help of a little consistency in naming, it's at least possible to start disentangling the two error types and the standard lib can set a good example here.
* change some Exceptions to CatchableError or Defect, fixes #10288 (#14069)hlaaftana2020-04-221-2/+2
|
* Make file descriptors from stdlib non-inheritable by default (#13201)alaviss2020-04-201-8/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * io: make file descriptors non-inheritable by default This prevents file descriptors/handles leakage to child processes that might cause issues like running out of file descriptors, or potential security issues like leaking a file descriptor to a restricted file. While this breaks backward compatibility, I'm rather certain that not many programs (if any) actually make use of this implementation detail. A new API `setInheritable` is provided for the few that actually want to use this functionality. * io: disable inheritance at file creation time for supported platforms Some platforms provide extension to fopen-family of functions to allow for disabling descriptor inheritance atomically during File creation. This guards against possible leaks when a child process is spawned before we managed to disable the file descriptor inheritance (ie. in a multi-threaded program). * net, nativesockets: make sockets non inheritable by default With this commit, sockets will no longer leak to child processes when you don't want it to. Should solves a lot of "address in use" that might occur when your server has just restarted. All APIs that create sockets in these modules now expose a `inheritable` flag that allow users to toggle inheritance for the resulting sockets. An implementation of `setInheritance()` is also provided for SocketHandle. While atomically disabling inheritance at creation time is supported on Windows, it's only implemented by native winsock2, which is too much for now. This support can be implemented in a future patch. * posix: add F_DUPFD_CLOEXEC This command duplicates file descriptor with close-on-exec flag set. Defined in POSIX.1-2008. * ioselectors_kqueue: don't leak file descriptors File descriptors internally used by ioselectors on BSD/OSX are now shielded from leakage. * posix: add O_CLOEXEC This flag allows file descriptors to be open() with close-on-exec flag set atomically. This flag is specified in POSIX.1-2008 * tfdleak: test for selectors leakage Also simplified the test by using handle-type agnostic APIs to test for validity. * ioselectors_epoll: mark all fd created close-on-exec File descriptors from ioselectors should no longer leaks on Linux. * tfdleak: don't check for selector leakage on Windows The getFd proc for ioselectors_select returns a hardcoded -1 * io: add NoInheritFlag at compile time * io: add support for ioctl-based close-on-exec This allows for the flag to be set/unset in one syscall. While the performance gains might be negliable, we have one less failure point to deal with. * tfdleak: add a test for setInheritable * stdlib: add nimInheritHandles to restore old behaviors * memfiles: make file handle not inheritable by default for posix * io: setInheritable now operates on OS file handle On Windows, the native handle is the only thing that's inheritable, thus we can assume that users of this function will already have the handle available to them. This also allows users to pass down file descriptors from memfiles on Windows with ease, should that be desired. With this, nativesockets.setInheritable can be made much simpler. * changelog: clarify * nativesockets: document setInheritable return value * posix_utils: atomically disable fd inheritance for mkstemp
* Deprecate DCE:on (#13839)Juan Carlos2020-04-021-1/+0
|
* fix deprecations and other warnings (#13748)Miran2020-03-251-4/+2
|
* introduce getPeerCertificates, fixes #13299 (#13650)Christian Ulrich2020-03-221-0/+34
| | | | | | | | | | | | * make i2d_X509 and d2i_X509 always available i2d_X509 and d2i_X509 have been available in all versions of OpenSSL, so make them available even if nimDisableCertificateValidation is set. * introduce getPeerCertificates, fixes #13299 getPeerCertificates retrieves the verified certificate chain of the peer we are connected to through an SSL-wrapped Socket/AsyncSocket. This introduces the new type Certificate which stores a DER-encoded X509 certificate.
* SSL certificate verify GitHub action (#13697)Federico Ceratto2020-03-201-12/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement SSL/TLS certificate checking #782 * SSL: Add nimDisableCertificateValidation Remove NIM_SSL_CERT_VALIDATION env var tests/untestable/thttpclient_ssl.nim ran successfully on Linux with libssl 1.1.1d * SSL: update integ test to skip flapping tests * Revert .travis.yml change * nimDisableCertificateValidation disable imports Prevent loading symbols that are not defined on older SSL libs * SSL: disable verification in net.nim ..when nimDisableCertificateValidation is set * Update changelog * Fix peername type * Add define check for windows * Disable test on windows * Add exprimental GitHub action CI for SSL * Test nimDisableCertificateValidation
* [backport] Fix style issues in lib/, tools/, and testament/. Fixes #12687. ↵3n-k12019-11-281-74/+74
| | | | (#12754)
* documented behaviour of recv on bufferd socket (#12374)Gampol T2019-10-091-0/+18
|
* [backport] run nimpretty on web stuffnarimiran2019-09-301-28/+33
|
* Fix spellings (#12277) [backport]Federico Ceratto2019-09-271-3/+3
|
* Update OpenSSL example (#11896)Federico Ceratto2019-08-211-1/+5
| | | | | | | | * Update OpenSSL example Fix privkey filename. Bump up RSA key size. Add ECDSA example.
* fixes #11925Araq2019-08-161-1/+1
|
* style improvements; fixes #11774Araq2019-07-191-1/+1
|
* Use std/monotimes in the stdlibOscar Nihlgård2019-07-161-9/+10
|
* there is only one style -- my styleAraq2019-07-101-0/+5
|
* make more parts of the stdlib compile with --styleCheck:errorAraq2019-07-101-4/+4
|
* styleCheck: make the compiler and large parts of the stdlib compatible with ↵Araq2019-07-101-14/+20
| | | | --styleCheck:error
* newruntime for async (#11650)Andreas Rumpf2019-07-051-6/+6
| | | | | | | * fixes overloading resolution for passing owned(Future[string]) to Future[T] * WIP: make --newruntime work with .async * memtracker: make it compile again * make Nimble compile again
* Make net module compile with --taintMode:on (#11360)Smittyvb2019-06-011-1/+1
|
* fixes #1286; object case transitions are now soundAndreas Rumpf2019-05-271-16/+12
|
* Update outdated ETimeout exception nameZestyr2019-05-071-6/+6
|
* Detect local "primary" IP addressFederico Ceratto2019-03-171-0/+20
|
* Handle IPv6 in bindAddr #7633Federico Ceratto2019-02-231-13/+12
| | | | Add test
* Show correct address for ipv6 sockets, fixes #7634 (#10505)LemonBoy2019-01-311-1/+1
|
* Fix spelling errors (#10379)Federico Ceratto2019-01-191-19/+19
|
* Remove long deprecated stuff (#10332)Miran2019-01-181-37/+2
|
* Merge pull request #9915 from zevv/asyncnet-unixDominik Picheta2018-12-121-7/+0
|\ | | | | Added basic AF_UNIX support to asyncnet.
| * Added basic AF_UNIX support to asyncnet.Ico Doornekamp2018-12-091-7/+0
| | | | | | | | | | | | | | | | Unfortunately this required some code duplication because the doConnect() from asynccommon.nim only works with addrInfo which does not make sense for AF_UNIX. makeUnixAddr() was moved to nativesocket.nim and exported
* | stdlib: documenation updates, the exception names have been changedAndreas Rumpf2018-10-251-14/+14
|/
* Convert *_family fields to cushortLemonBoy2018-09-191-7/+4
| | | | Fixes #9008
* Fix connectUnix/bindUnix with abstract socket pathsLemonBoy2018-09-151-2/+2
| | | | | | | The only way to make this work for both abstract and non-abstract sockets is to send the kernel an incomplete structure. Reported by Epictek on the forum.
* Net module fixes (#8597)Dominik Picheta2018-08-281-17/+16
| | | | | * net.accept no longer needs an initialised socket. Fixes #7848. * Assert error when using sendTo/recvFrom on TCP socket. * net.sendTo now raises OSError.
* WIP: disallow 'nil' for strings and seqsAndreas Rumpf2018-08-131-24/+24
|
* Update example code for UDP socketsEuan T2018-07-301-1/+1
|
* Fixed compilation error when Sockaddr_in4 or Sockaddr_in6 passed to fromSockAddrYuriy Glukhov2018-06-071-1/+1
|
* Fix one more place.cheatfate2018-06-071-1/+1
|
* Fix fromSockAddrAux() to handle IPv6 addresses properly.cheatfate2018-06-071-9/+16
|
* Merge pull request #7822 from data-man/fix_2753Andreas Rumpf2018-06-071-1/+1
|\ | | | | Fixes #2753
| * Fixes #2753data-man2018-05-141-1/+1
| |
* | Set domain to clientWhiteDuke2018-05-271-0/+1
|/
* Add connectUnix and bindUnix to net docsMathias Stearn2018-05-091-1/+1
| | | fixes #7715
* remove deprecated stuff from the stdlib; introduce better deprecation warningsAraq2018-05-051-9/+0
|
* fixed high level sendTo for sending to udp6 (#7630)David Krause2018-05-021-3/+2
|