aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
AgeCommit message (Collapse)Author
2018-01-03Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa
2017-12-13Merge #11363: net: Split socket create/connectWladimir J. van der Laan
3830b6e net: use CreateSocket for binds (Cory Fields) df3bcf8 net: pass socket closing responsibility up to caller for outgoing connections (Cory Fields) 9e3b2f5 net: Move IsSelectableSocket check into socket creation (Cory Fields) 1729c29 net: split socket creation out of connection (Cory Fields) Pull request description: Requirement for #11227. We'll need to create sockets and perform the actual connect in separate steps, so break them up. #11227 adds an RAII wrapper around connection attempts, as a belt-and-suspenders in case a CloseSocket is missed. Tree-SHA512: de675bb718cc56d68893c303b8057ca062c7431eaa17ae7c4829caed119fa3f15b404d8f52aca22a6bca6e73a26fb79e898b335d090ab015bf6456cf417fc694
2017-12-12net: pass socket closing responsibility up to caller for outgoing connectionsCory Fields
This allows const references to be passed around, making it clear where the socket may and may not be invalidated.
2017-12-12net: Move IsSelectableSocket check into socket creationCory Fields
We use select in ConnectSocketDirectly, so this check needs to happen before that. IsSelectableSocket will not be relevant after upcoming changes to remove select.
2017-12-12net: split socket creation out of connectionCory Fields
Also, check for the correct error during socket creation
2017-11-16Remove includes in .cpp files for things the corresponding .h file already ↵practicalswift
included
2017-11-16scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider
-BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
2017-10-09Fix a vs. an typopracticalswift
2017-09-28Merge #10663: net: split resolve out of connectWladimir J. van der Laan
b887676 net: remove now-unused functions (Cory Fields) 45fd754 net: remove now-superfluous numeric resolve (Cory Fields) 2416dd7 net: separate resolving and conecting (Cory Fields) Pull request description: This is a greatly simplified version of #10285, which only aims to address async resolving. It essentially breaks up two wrapper functions for things only used in one place (ConnectSocketDirectly/ConnectThroughProxy) in favor of calling them directly. This allows us to fully handle resolves before attempting a connection, as is necessary for async connections. As a bonus, I believe the logic is now much easier to follow than before. Tree-SHA512: f03f618107379edf3efe2a9f3e3677e8f075017ab140a0b4fdc3b8263e6beff148d55256263ab10bc2125ef089ca68e0d8e865beeae176f1eca544e769c976d3
2017-09-26net: Improve and document SOCKS codeWladimir J. van der Laan
Make the SOCKS code more consistent, and document the constants used.
2017-09-18net: remove now-unused functionsCory Fields
2017-09-18net: separate resolving and conectingCory Fields
ConnectSocketByName handled resolves as necessary, obscuring the connection process. With them separated, each can be handled asynchronously. Also, since proxies must be considered now anyway, go ahead and eliminate the ConnectSocket wrapper and use ConnectSocketDirectly... directly.
2017-08-07scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal ↵practicalswift
instead of the macro NULL -BEGIN VERIFY SCRIPT- sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp -END VERIFY SCRIPT-
2017-07-22Move CloseSocket out of SetSocketNonBlocking and pass SOCKET by const ↵Dag Robole
reference in SetSocket* functions
2017-07-15Merge #10812: [utils] Allow bitcoin-cli's -rpcconnect option to be used with ↵Pieter Wuille
square brackets 5c643241e [utils] allow square brackets for ipv6 addresses in bitcoin-cli (John Newbery) fe4fabaf1 [refactor] move SplitHostPort() into utilstrencodings (John Newbery) Pull request description: bitcoin-cli's `-rpcconnect` can accept ipv6 addresses (as long as the libevent version is new enough), but fails to parse ipv6 with square brackets. This PR makes `bitcoin-cli` parse ipv6 in square brackets correctly. `bitcoin-cli -rpcconnect=[::1] <command>` should now be equivalent to `bitcoin-cli -rpcconnect=::1 <command>` This is useful so the `bitcoin-cli` option can now be in the same format as the `bitcoind` option. Doesn't include tests. I have a branch that fully tests `bitcoin-cli`, but that's queued behind several intermediate PRs. - first commit moves `SplitHostPort()` from libbitcoin_common into libbitcoin_util - second commit adds proper ipv6 parsing to bitcoin-cli Tree-SHA512: 249d409f10360c989474283341f458cc97364a56a7d004ae6d5f13d8bffe3a51b5dc2484d42218848e2d42cd9c0b13a1b92e94ea19b209f7e91c875c208d8409
2017-07-13Fix uninitialized atomic variablesJoão Barbosa
2017-07-12[refactor] move SplitHostPort() into utilstrencodingsJohn Newbery
This moves SplitHostPort from libbitcoin_common to libbitcoin_util so it is available to bitcoin-cli.
2017-06-14net: do not allow resolving to an internal addressCory Fields
In order to prevent mixups, our internal range is never allowed as a resolve result. This means that no user-provided string will ever be confused with an internal address.
2017-05-23Merge #9539: [net] Avoid initialization to a value that is never readWladimir J. van der Laan
5844609 [net] Avoid initialization to a value that is never read (practicalswift) Tree-SHA512: 068c3fba58034187f546688bc9b8b7317e0657e797850613fb6289a4efc28637e4d06a0fa5e57480538c6b8340ed6d6a6c6f9a96f130b698d5d60975490a03d8
2017-05-17Merge #10061: [net] Added SetSocketNoDelay() utility functionPieter Wuille
ad415bc [net] Added SetSocketNoDelay() utility function (Thomas Snider) Tree-SHA512: c19e3c9910b3fc2ef86f2434f3e91d343e9cd9e2116153941de9789e2a6fc0389bffe762d21b55cda4a4b1de993afee0564c6946e65d05cef9e866b58896f9af
2017-04-05[net] Added SetSocketNoDelay() utility functionThomas Snider
2017-04-01Change LogAcceptCategory to use uint32_t rather than sets of strings.Gregory Maxwell
This changes the logging categories to boolean flags instead of strings. This simplifies the acceptance testing by avoiding accessing a scoped static thread local pointer to a thread local set of strings. It eliminates the only use of boost::thread_specific_ptr outside of lockorder debugging. This change allows log entries to be directed to multiple categories and makes it easy to change the logging flags at runtime (e.g. via an RPC, though that isn't done by this commit.) It also eliminates the fDebug global. Configuration of unknown logging categories now produces a warning.
2017-03-05build: cleanup: define MSG_DONTWAIT/MSG_NO_SIGNAL locallyWladimir J. van der Laan
Define MSG_DONTWAIT and MSG_NO_SIGNAL in the implementation files that use them (`net.cpp` and `netbase.cpp`), instead of compat.h which is included all over the place. This avoids putting them in the global namespace, as defining them as 0 is a hack that works for our specific usage, but it is not a general solution. Also makes sure they are defined only once so the `!defined(MSG_x)` guard can go.
2017-02-28[net] Avoid initialization to a value that is never readpracticalswift
Prior to this commit the value stored to `s` at initialization was never read (in the case of STRERROR_R_CHAR_P).
2017-02-09netbase: Do not print an error on connection timeouts through proxyWladimir J. van der Laan
If a timeout happens while reading the proxy response, this effectively means we timed out while connecting to the remote node. This is very common for Tor, so do not print an error message.
2017-02-09netbase: Make InterruptibleRecv return an error code instead of boolWladimir J. van der Laan
2017-01-04Merge #9289: net: drop boost::thread_groupWladimir J. van der Laan
67ee4ec net: misc header cleanups (Cory Fields) 8b3159e net: make proxy receives interruptible (Cory Fields) 5cb0fce net: remove thread_interrupted catch (Cory Fields) d3d7056 net: make net processing interruptible (Cory Fields) 0985052 net: make net interruptible (Cory Fields) 799df91 net: add CThreadInterrupt and InterruptibleSleep (Cory Fields) 7325b15 net: a few small cleanups before replacing boost threads (Cory Fields)
2017-01-03net: misc header cleanupsCory Fields
2017-01-03net: make proxy receives interruptibleCory Fields
2016-12-31Increment MIT Licence copyright header year on files modified in 2016isle2983
Edited via: $ contrib/devtools/copyright_header.py update .
2016-12-09Refactor: Removed begin/end_ptr functions.Karl-Johan Alm
2016-12-01Revert "Use async name resolving to improve net thread responsiveness"Matt Corallo
This reverts commit caf6150e9785da408f1e603ae70eae25b5202d98. getaddrinfo_a has a nasty tendency to segfault internally in its background thread, on every version of glibc I tested, especially under helgrind. See https://sourceware.org/bugzilla/show_bug.cgi?id=20874
2016-10-17Kill insecure_random and associated global stateWladimir J. van der Laan
There are only a few uses of `insecure_random` outside the tests. This PR replaces uses of insecure_random (and its accompanying global state) in the core code with an FastRandomContext that is automatically seeded on creation. This is meant to be used for inner loops. The FastRandomContext can be in the outer scope, or the class itself, then rand32() is used inside the loop. Useful e.g. for pushing addresses in CNode or the fee rounding, or randomization for coin selection. As a context is created per purpose, thus it gets rid of cross-thread unprotected shared usage of a single set of globals, this should also get rid of the potential race conditions. - I'd say TxMempool::check is not called enough to warrant using a special fast random context, this is switched to GetRand() (open for discussion...) - The use of `insecure_rand` in ConnectThroughProxy has been replaced by an atomic integer counter. The only goal here is to have a different credentials pair for each connection to go on a different Tor circuit, it does not need to be random nor unpredictable. - To avoid having a FastRandomContext on every CNode, the context is passed into PushAddress as appropriate. There remains an insecure_random for test usage in `test_random.h`.
2016-08-15Do not shadow variables in networking codePavel Janík
2016-08-04net: Have LookupNumeric return a CService directlyCory Fields
Also fix up a few small issues: - Lookup with "badip:port" now sets the port to 0 - Don't allow assert to have side-effects
2016-07-31net: move CNetAddr/CService/CSubNet out of netbaseCory Fields
2016-07-31net: Split resolving out of CSubNetCory Fields
2016-07-31net: Split resolving out of CServiceCory Fields
2016-07-31net: Split resolving out of CNetAddrCory Fields
2016-06-13Randomize name lookup result in ConnectSocketByNamePieter Wuille
2016-05-19Use Socks5ErrorString() to decode error responses from socks proxy.Warren Togami
2016-05-17Make Socks5() InterruptibleRecv() timeout/failures informative.Warren Togami
Before: 2016-05-16 06:10:45 ERROR: Error reading proxy response After: 2016-05-16 06:10:45 Socks5() connect to k7s5d6jqig4ej4v4.onion:18333 failed: InterruptibleRecv() timeout or other failure
2016-05-09SOCKS5 connecting and connected messages with -debug=net.Warren Togami
They were too noisy and not necessary for normal operation.
2016-05-09Make failures to connect via Socks5() more informative and less ↵Warren Togami
unnecessarily scary. * The "ERROR" was printed far too often during normal operation for what was not an error. * Makes the Socks5() connect failure similar to the IP connect failure in debug.log. Before: `2016-05-09 00:15:00 ERROR: Proxy error: host unreachable` After: `2016-05-09 00:15:00 Socks5() connect to t6xj6wilh4ytvcs7.onion:18333 failed: host unreachable"`
2016-04-20net: disable resolving from storage structuresCory Fields
CNetAddr/CService/CSubnet can no longer resolve DNS.
2016-04-20net: resolve outside of storage structuresCory Fields
Rather than allowing CNetAddr/CService/CSubNet to launch DNS queries, require that addresses are already resolved. This greatly simplifies async resolve logic, and makes it harder to accidentally leak DNS queries.
2016-04-05Net: Add IPv6 Link-Local Address Supportmruddy
2016-01-17Typo fixes in commentsChris Wheeler
2015-12-13Bump copyright headers to 2015MarcoFalke
2015-11-28[trivial] Reuse translation and cleanup DEFAULT_* valuesMarcoFalke
* DEFAULT_DISABLE_SAFEMODE = false * Use DEFAULT_* constants for extern bools