Commit Graph
187 Commits
Author SHA1 Message Date
Logan oos EvenandGitHub ffb4e31b8a encapsulated several fillings of n2n_sock_t in single function (#1025)
* encapsulated several fillings of n2n_sock_t in single function

* Windows specifics...

* stuck to the project's style code
2022-06-26 00:07:29 +02:00
Logan oos EvenandGitHub 51a3a71f95 introduced n2n-portfwd tool (#1008)
* moved dev to version 3.1.1

* introduced n2n-portfwd tool

* moved port-forwarding source to tool

* adjusted tiny things, seemingly works with ./configure's  --enable-miniupnp  and  --enable-natpmp

* adjusted for Windows

* wished for better typing skills

* applied some finishing touch

* typo
2022-06-05 18:05:40 +02:00
Logan oos EvenandGitHub 99b6b6b66d added n2n-route tool (#982)
* moved dev to version 3.1.1

* laid ground for n2n-route tool

* adapted code style

* overhauled n2n-route's tool program logic and removed route code from edge

* added missing initialization of federation's purgeable field

* lifted un/purgeable confusion

* added warning about removed -n cli option

* realized that Windows does not offer inet_aton()

* removed -n option documentation from edge's man page

* slightly simplified n2n-route program logic

* applied more logic changes to n2n-route tool

* added 'info' read command to edge's management port

* corrected indention

* added Linux route control to n2n-route tool

* temporarily restricted n2n-route tool to Linux only

* We must be over the routing!

* pulled default gateway change detection into main loop to cover mobile use, and added devstr_t type

* corrected use of new UNPURGEABLE - so far gone unnoticed

* addresses possiible address issue

* i broke it

* reverted bad ideas

* added command line options, help text, and prevented vpn gateway being used for supernode/peer traffic routes

* added option to manually provide default gateway, also verbosity options

* getting there

* added option to limit networks to be routed (-n), adapted documentation

* fine-tuned minor things
2022-05-24 20:38:51 +02:00
Hamish Coleman afd0020d16 Refactor sendto_fd and friends in an attempt to find anything that could segfault 2022-05-17 23:33:41 +01:00
Hamish Coleman 038c244407 Fix supernode memory leak on exit path 2022-05-08 17:28:05 +01:00
Hamish ColemanandGitHub 009311d016 Provide better details when sendto_fd fails (#981)
* Refactor traceEvent to allow variable log levels

* Refactor sendto failed for less repetition

* Refactor sendto_fd to make control flow clearer, also reduce repetition

* Tie size to the actual object not its class

* Show destination that had issues when sendto_fd fails

* Fix MSVC compile - it doesnt support the same variadic macros as gcc
2022-04-25 19:13:14 +02:00
Logan oos EvenandGitHub e686b9592c (C) update (#965) 2022-03-12 10:22:42 +01:00
Logan oos EvenandGitHub f59c6900a1 moved compression code into transforms (#961) 2022-02-21 10:09:06 +01:00
Hamish Coleman 860b27d97c Add event publishing for adding and removing P2P peers 2022-02-05 20:06:31 +00:00
Hamish Coleman a8e2704b41 Move all management packet handling for edge into the one source file 2022-02-05 20:06:31 +00:00
Hamish ColemanandGitHub 4f568b03c1 Autoconf simplification (#927)
* Convert zstd feature to default disable

* All autoconf test use one standard template

To simplify the testing, cross-compilation and repeatable build process,
no configure options are automatically probed for - they all default to
off and are all using the same template.

The --with-x options should be deprecated and replaced with --enable-x
because there is no syntax checking for --with options in autoconf.

There are still some differences between the config options, but this
should provide a starting point.

* Remove unused code from the autoconf

* Remove warnings from default build

* Avoid calling port mapping functions if none are enabled

* Start with all builds in neutral config

* Add more missing code guards

* Adjust code guard location to placate cmake
2022-01-10 19:58:15 +00:00
e6e8cb038a added port forwarding (upnp and natpmp) (#905)
* UPnP port redirection is supported.

* compile fixes

* compile fix

* optimize reconnection code

* prepared upnp threadification to counter main loop stall at supernode change

* NAT-PMP port forwarding support, temporarily merge codes to resolve conflicts.

* make compile fix

* prepared threadification in more detail

* adopted threadification to new file setup

* cleaned up

* renamed functions and data structures

* fixes

* differentiated between miniupnp and natpmp and added corresponding lib support to makefile

* name

* commented unused header includes

* comments

* license

* fixes

* fixes

* fixes

* NAT-PMP is already available.

* added CLI parameter to disable port forwarding if required

* preliminary made use of multithreading

* adjusted log level

* added man page documentation

* def'ed conf

* made pmpnat adjustments

Co-authored-by: fengdaolong <fengdaolong@gmail.com>
2021-12-23 12:27:55 +01:00
Logan oos EvenandGitHub c5f9e8198b had the edge output supernode version to log on incoming PONG (#894) 2021-11-07 16:53:01 +05:45
Logan oos EvenandGitHub ecff46a043 applied tiny optimization to PACKET's code path (#882) 2021-10-31 22:38:56 +05:45
Logan oos EvenandGitHub 3b187b4ac8 updated JSON API password handling '--management-password <pw>' (#869) 2021-10-24 15:22:36 +05:45
Logan oos EvenandGitHub c61b62ab1b choose supernode selection strategy at run-time '--select-rtt' (#864) 2021-10-24 12:53:25 +05:45
Hamish ColemanandGitHub ae502d9181 JSON Reply Management API - feature parity with old management interfaces (#861)
* Ensure that recent code additions pass the linter

* Include some of the more obviously correct lint fixes to edge_utils.c

* Refactor edge JSON api into its own source file

* Use shorter names for static management functions

* Implement a JSON RPC way of managing the verbosity

* Tidy up help display in n2nctl script

* Make note of issue with implementing the stop command

* Implement a JSON RPC call to fetch current community

* Make n2nhttpd time value be more self-contained

* Make n2nhttpd order more closely match the existing management stats output

* Wire up status page to the verbosity setting

* Add JSON versions of the remainder of the edge management stats

* Add new file to cmake

* Properly define management handler

* Only update the last updated timestamp after a successful data fetch

* Function and types definition cleanup

* Force correct type for python scripts mgmt port

* Implement initial JSON API for supernode

* Fix whitespace error

* Use helper function for rendering peers ip4 address

* Proxy the auth requirement back out to the http client, allowing normal http auth to be used

* Ensure that we do not leak the federation community

* Use the same rpc method name and output for both edge and supernode for peers/edges

* Allow n2nctl to show raw data returned without resorting to tricks

* Make n2nctl pretty printer understandable with an empty table

* Use the full name for supernodes RPC call

* Use same RPC method name (but some missing fields) for getting communities from both edge and supernode

* Add *_sup_broadcast stats to edge packet stats output

* Refacter the stats into a packetstats method for supernode RPC

* Even if I am not going to prettyprint the timestamps, at least make all the timestamps on the page the same unit

* Simplify the RPC handlers by flagging some as writable and checking that in the multiplexer

* Remove invalid edges data

* Avoid crash on bad data to verbose RPC

* Avoid showing bad or inconsistant protocol data in communities RPC

* Minor clarification on when --write is handled

* Make linter happy

* Fix changed method name in n2nhttpd

* Move mainloop stop flag into the n2n_edge_t structure, allowing access from management commands

* Implement edge RPC stop command

* Move mainloop stop flag into the n2n_sn_t structure, allowing access from management commands

* Implement supernode RPC stop command

* Allow multiple pages to be served from mini httpd

* Extract common script functions into a separate URL

* Handle an edge case in the python rpc class

With a proper tag-based demultiplexer, this case should be a nop,
but we are single-threaded and rely on the packet ordering in this
library.

* Add n2nhttpd support to query supernode using urls prefixed with /supernode/

* Handle missing values in javascript table print

* Add another less filtering javascript key/value renderer

* Add a supernode.html page to the n2nhttpd

* Address lint issue

* Mention the second html page on the Scripts doc

* Remove purgable column from supernode edges list - it looks like it is rarely going to be set

* Add a simple one-line example command at the top of the API documentation

* Acknowledge that this is not the most efficient protocol, but point out that it was not supposed to be

* Make it clear that the n2nctl script works for both edge and supernode

* Fight with inconsistant github runner results

* Turn off the /right/ coverage generator
2021-10-23 11:05:05 +05:45
Hamish ColemanandGitHub e6fcf1c55b Cleanup and Documentation for JSON management API (#856)
* Reimplement JSON mgmt with clear separation of read/write actions

* Reduce boilerplate by using a table driven command definition for json mgmt commands

* Port tools to use new json api

* Add a basic authentication for json mgmt commands

* If a auth key is given, it must match

* Add auth key to management scripts

* Add a flag bitfield to clearly turn the tag param into a options list

* Allow simple pass-through of any command from n2nctl

* Convert the n2nctl to use an object oriented interface

* Handle sigpipe in the n2nhttpd - this happens if the remote client disconnects unexpectely

* Remove some repetition from the server

* Use the correct options to allow reuseaddr

* Dont generate a scary message on ctrl-c

* Convert n2nhttpd to use object based RPC

* Use the same longopt for both tools

* Pass any extra args through to the RPC

* Add some documentation for the scripts in the repository

* Spelling fix

* Add documentation for the JSON reply mangement API
2021-10-18 02:01:42 +05:45
Hamish ColemanandGitHub bb3de5698c added JSON interfaces to edge management port and scripts to further process output (#854)
* Add management commands to show data in JSON format

* Add a script to query the JSON management interface

* Suprisingly, the github runner does not have flake8 installed

* Add n2nctl debugging output to show the raw data received from the JSON

* Ensure well known tag wrap-around semantics

* Try to ensure we check every edge case in the protocol handling - only valid packets are allowed

* Add a very simple http to management port gateway

* Fix the lint issue
2021-10-16 00:11:39 +05:45
Logan oos EvenandGitHub db5adc2038 fine-tuned REGISTER cookie handling (#837) 2021-10-03 18:19:29 +05:45
Logan oos EvenandGitHub bc65a7f59e added forwarded REGISTER cookie type (#836) 2021-10-03 05:24:33 +05:45
Logan oos EvenandGitHub ebb357245a added a flag field to QUERY_PEER (#835) 2021-10-02 23:17:45 +05:45
Logan oos EvenandGitHub 4137441b5e fine-tuned log levels (#827) 2021-09-29 13:38:55 +05:45
Logan oos EvenandGitHub 0d39f50051 created space for more REGISTER type cookies 2021-09-27 02:41:14 +05:45
Logan oos EvenandGitHub 40f1894956 hid community name at management port if header encryption enabled (#822) 2021-09-26 05:01:53 +05:45
Logan oos EvenandGitHub 56a81f02b8 fixes (#819) 2021-09-26 00:17:47 +05:45
Logan oos EvenandGitHub dfe15ad95d added support for N2N_PASSWORD environment variable (#818) 2021-09-25 16:01:11 +05:45
09fdfb0424 added support for COMMUNITY_NAME environment variable (#814)
Co-authored-by: codeneno <qsmy_qin@163.com>
Co-authored-by: Logan oos Even <Logan.00sEven@gmail.com>
2021-09-25 15:15:16 +05:45
Logan oos EvenandGitHub f093996535 moved up 'send_unregister_super()' to happen before 'WaitForSingleObject()' (Windows TAP thread's end) 2021-09-23 15:54:55 +05:45
lucktuandGitHub c4d56574ef polished edge's management port output (#805) 2021-09-20 18:01:07 +05:45
Luca Deri d4e0f5a445 Warnign fixes 2021-09-18 09:39:57 +02:00
Logan oos EvenandGitHub 37c556b57b modified edge's management port output (#801) 2021-09-18 01:04:24 +05:45
Logan oos EvenandGitHub dd41689bb9 added supernode version and uptime information to edge management port output (#796) 2021-09-17 02:34:09 +05:45
Logan oos EvenandGitHub 593387fe30 compile fix (#794) 2021-09-16 15:07:33 +05:45
Hamish ColemanandGitHub 370ea9bd37 addressed all but one of the remaining compile warnings (#793)
* Fix the mismatched char, uint8_t warnings

* Ensure we leave room for zero termination and then ensure the string is terminated

* GCC has a warning if it thinks your could overflow your snprintf buffer, but dont check for said overflow
2021-09-16 14:45:46 +05:45
Logan oos EvenandGitHub 9c22d28562 relocated 'detect_local_ip_address()' (#791) 2021-09-16 12:20:35 +05:45
Hamish ColemanandGitHub 6b353141b4 addressed warnings (#790) 2021-09-15 22:08:45 +05:45
Logan oos EvenandGitHub 72d703c449 disabled edge's multicast peer detection if used with '-e' (#783) 2021-09-13 21:03:35 +05:45
Logan oos EvenandGitHub b3bf36f867 separated 'detect_local_ip_address()' function (#781) 2021-09-13 11:33:27 +05:45
Logan oos EvenandGitHub 7f1fe9a499 allowed edge to optionally auto-detetct local IP address ('-e auto') for advertising as preferred (#776) 2021-09-12 00:22:05 +05:45
Logan oos EvenandGitHub defad50f87 removed '-p' cli option requirement for (#775) 2021-09-11 20:54:09 +05:45
Logan oos EvenandGitHub 7fa0cc1e0a added preferred socket handling (-e) (#765) 2021-09-09 14:07:29 +05:45
Logan oos EvenandGitHub 04d91f84d8 fixed optional SKIP_MULTICAST_PEERS_DISCOVERY macro (#770) 2021-09-08 00:56:05 +05:45
Logan oos EvenandGitHub 236b9bf4c7 fixed missing gratuitous arp (#769) 2021-09-07 01:36:51 +05:45
Logan oos EvenandGitHub b6e865aac7 trimmed open_socket() down by one parameter (#768) 2021-09-06 17:03:15 +05:45
Logan oos EvenandGitHub e13c9a01a5 rearranged thread-related code (#761) 2021-08-30 14:23:31 +05:45
Logan oos EvenandGitHub f6eb1377ec reviewed log messages (#744) 2021-08-29 15:10:23 +05:45
Logan oos EvenandGitHub c21accc2a1 enabled edge to bind to a specified IP address (-b) (#753) 2021-08-28 03:08:23 +05:45
Logan oos EvenandGitHub e09f3a4875 added federation support to user/password auth scheme (#741) 2021-07-31 22:17:07 +05:45
Logan oos EvenandGitHub c35129b8e2 added 'reload_communities' command to supernode management port (#740) 2021-07-24 03:46:50 +05:45