Commit Graph

159 Commits

Author SHA1 Message Date
Hamish Coleman
473b89c963 Simplify build system by using standard macro
Most environments have predefined macros that identify the environment
to the source code.  If we use these macros instead of defining our own
then there is one less parameter difference to keep track of with
different builds

cf:
    http://web.archive.org/web/20191012035921/http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
    https://sourceforge.net/p/predef/wiki/OperatingSystems/
2023-07-01 19:08:43 +08:00
Hamish Coleman
041233dc8b Address more windows compile warnings 2023-06-29 06:00:56 +08:00
Hamish Coleman
21ac30c121 Use the correct modern windows sockets header
As suggested in a PR from @Legend-Master (this change is basically
unrelated to the main point of his PR, so extracted here)

Windows is a confusing and disappointing development environment.  They
completely replaced all the definitions in winsock.h with exact
equivalents in winsock2.h (except for a small number of deprecated
functions).

However they didnt make them mutually exclusive - so if you include
both, you get errors.  They also automatically include winsock.h from
windows.h, so you must remember to include winsock2.h first.  They also
didnt just remove winsock.h and replace it with the new contents.

(Probably in the name of "compatibility", whilst swearing that the new
winsock is the same as the old one - because if you cannot believe two
inconsistent things simultaneously, you shouldnt be a windows
programmer)

All these things are totally nuts.  Thanks, windows dev environment,
for not noticing that this is nuts
2023-06-25 02:46:03 +08:00
Hamish Coleman
a7fc1c2bbc Merge branch 'dev' into iwyu 2023-06-18 12:31:58 +01:00
Tony
76cbff370e
Fix purgeable is always false on supernode peer list (#1117)
* Fix purgeable is always false on sn peer list
- And change sn_purge to bool

* Change all keep_on_running to bool

* Fix wrong `keep_running` type
2023-06-18 08:58:49 +01:00
Hamish Coleman
6ee14559f9 iwyu: sn_utils.c 2023-06-16 09:26:04 +01:00
Hamish Coleman
4e0bec79b7 iwyu: speck.h 2023-06-14 20:30:43 +01:00
Hamish Coleman
f67cc8f2a6 iwyu: random_numbers.h 2023-06-14 20:14:11 +01:00
Hamish Coleman
15ad901b41 iwym: pearson.h 2023-06-14 20:02:54 +01:00
Hamish Coleman
4838dd8d75 iwym: header_encryption.h 2023-06-13 22:38:47 +01:00
Hamish Coleman
ae3d54eed6 iwym: auth.h 2023-06-13 21:24:30 +01:00
Logan oos Even
053ab381b3
fixed endianess issue in federated sn socket forwarding (#1030) 2022-06-28 16:53:12 +02:00
Logan oos Even
95cfbca5a9
more sockaddr generalization (#1028) 2022-06-27 22:21:03 +02:00
Logan oos Even
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 Even
7927bd7294
added optional choice of bind address (-p) to supernode (#1016) 2022-06-16 12:00:48 +02:00
Logan oos Even
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
47768758d6 Fix use before null check 2022-05-08 17:51:00 +01:00
Logan oos Even
5f60a6b333
made supernode ignore own registration attempts to allow unified configuration (command line-provided supernodes) of federated supernodes (#970) 2022-03-20 12:48:40 +01:00
Logan oos Even
e686b9592c
(C) update (#965) 2022-03-12 10:22:42 +01:00
Hamish Coleman
4b8aaa7f6e
Merge pull request #947 from hamishcoleman/json_pubsub
Add JSON pubsub framework for edge
2022-02-12 10:59:52 +00:00
Logan oos Even
cbad152994
limited federation broadcast to active supernodes only (#958) 2022-02-12 11:35:22 +01:00
Hamish Coleman
ace3dbc44f Move all supernode management handling into one source file 2022-02-05 20:06:31 +00:00
Hamish Coleman
00a2bdc307 Remove all use of N2N_VERSION_SHORT in favor of PACKAGE_VERSION 2021-11-01 19:15:23 +00:00
Hamish Coleman
a9216f1097 Remove GIT_RELEASE variable and use the semantically identical N2N_VERSION instead 2021-11-01 19:15:23 +00:00
Logan oos Even
3b187b4ac8
updated JSON API password handling '--management-password <pw>' (#869) 2021-10-24 15:22:36 +05:45
Logan oos Even
c61b62ab1b
choose supernode selection strategy at run-time '--select-rtt' (#864) 2021-10-24 12:53:25 +05:45
Hamish Coleman
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
Logan oos Even
50d4273272
disabled federation name output at supernode's management port (#845) 2021-10-07 13:56:03 +05:45
Hamish Coleman
4438f1aa2a
added mingw test platform (#829)
* Provide a minimal reimplementation of our autoconf, to try windows builds

* Try building with windows

* Fix thinko in spelling

* Ensure shell script runs inside a shell

* Add a hack to aid include discovery

* Just keep adding tech debt...

* Assume that we will have slashes in some of the replacement strings and avoid that char with sed

* Restore one slash

* Hack around the tools makefile interdependancy bug

* A correct cflags include hack for each compile dir

* Ensure we link against winsock (note, even though this says 32bit, it should link the 64bit library ... I think)

* Bad link ordering if we dont use LDLIBS

* Remove unused make variable

* Remove makefile duplication using inheritance (this does mean you can no longer cd tools; make, but must do make tools)

* Add missing library for win32

* Show OS variable

* Make hack autoconf more robust for tests on non gitlab runners

* Remove no longer used substitutions from hack autoconf

* Add missing include path to tools under win32

* Build the win32 subdir when the compiler is Msys

* The different subdirs have different dependancies

* Ensure we can find the include files

* Fix library link ordering

* Ensure the tools dir can find the special win32 lib

* Deal with the differing basic type sizes on both linux/64bit and windows/64bit

* Document the steps to mimic the github windows/mingw build locally - to allow for simpler debugging

* Ensure branch name in instructions matches my test branch name

* Clarify the shell needed to build with mingw

* Since the makefile depends on knowing the OS, raise a fatal error if we cannot determine this

* Handling different compile environments is hard.

- Linux: sane and reasonable results for both uname -s (=Linux) and
  uname -o (=GNU/Linux)
- Windows/Mingw: insane results for uname -s
  (=MSYS_NT-$MAJOR.$MINOR-$BUILDNR) but sane results for uname -o (Msys)
- Macos: sane results for uname -s (=Darwin) but does not support
  uname -o at all

* Revamp the way that Mingw is detected

* Avoid attempting to generate gcovr report when running under windows

* Whoops, isolate the right step

* Fix spelling mistake

* win32/Makefile: Remove unused setting and add comment

* ensure that all win32 includes use the same expected path

* Allow simpler cross compilation by letting configure pass the CC and AR environment through

* Avoid multiple '_CRT_SECURE_NO_WARNINGS redefined' warnings

* Convert to a consolidated CONFIG_TARGET variable to select any different compile options

* Use the more generic printf defines to avoid warnings on mingw

* Update mingw build docs

* English better for reader happy make

* Address a number of mingw compiler warnings

* Fix Visual C compile

* Be sure to document some of the hacky nature of the mingw build
2021-10-06 00:52:15 +05:45
Logan oos Even
cc2b0b6b6b
added support for N2N_FEDERATION environment variable (#820) 2021-09-26 04:32:12 +05:45
Logan oos Even
56a81f02b8
fixes (#819) 2021-09-26 00:17:47 +05:45
Logan oos Even
dd41689bb9
added supernode version and uptime information to edge management port output (#796) 2021-09-17 02:34:09 +05:45
Hamish Coleman
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
Hamish Coleman
6b353141b4
addressed warnings (#790) 2021-09-15 22:08:45 +05:45
Logan oos Even
7fa0cc1e0a
added preferred socket handling (-e) (#765) 2021-09-09 14:07:29 +05:45
Logan oos Even
e13c9a01a5
rearranged thread-related code (#761) 2021-08-30 14:23:31 +05:45
Logan oos Even
f6eb1377ec
reviewed log messages (#744) 2021-08-29 15:10:23 +05:45
Hamish Coleman
ecedcdcb58
Major documentation improvements (#752) 2021-08-19 20:02:53 +05:45
Logan oos Even
e09f3a4875
added federation support to user/password auth scheme (#741) 2021-07-31 22:17:07 +05:45
Logan oos Even
c35129b8e2
added 'reload_communities' command to supernode management port (#740) 2021-07-24 03:46:50 +05:45
Logan oos Even
c394726928
narrowed sn's edge-last-seen update mechanism (#734)
* fortified user/pw auth scheme

* narrowed sn's edge-last-seen update mechanism
2021-07-22 14:51:09 +05:45
Logan oos Even
84d0991977
fortified user/pw auth scheme (#731) 2021-07-21 02:52:38 +05:45
Logan oos Even
39aa50b4cd
added manual MAC/IP address spoofing protection override at supernode (-M) (#716) 2021-06-21 17:03:07 +05:45
Logan oos Even
54f39e9eb0
fixed supernode's detetcion of orderly remote tcp connection closure (#713) 2021-06-17 22:16:45 +05:45
Logan oos Even
701befe6df
fixed superfluous message (#708) 2021-06-07 22:59:22 +05:45
Logan oos Even
aac58a88ec
fixed supernode's federation behavior (auth error) (#707) 2021-06-07 20:54:22 +05:45
Logan oos Even
1586ae62a7
made n2n react more swiftly to (D)DNS changes (#705) 2021-06-07 17:57:49 +05:45
Logan oos Even
3c6ab56d3f
allowed (temporarily) initially non-resolving supernode names (#701) 2021-06-05 17:54:32 +05:45
Logan oos Even
c55e3e3246
multithreaded supernode name resolution (#645) 2021-06-04 03:52:12 +05:45
Logan oos Even
a28327a0af
added user-password edge authentication (#673) 2021-06-04 03:11:22 +05:45