100 Commits
Author SHA1 Message Date
Hamish Coleman fff50a7d80 Ensure the code style is kept 2023-10-24 11:20:13 +01:00
Hamish Coleman d2bafa716d Fix API initialisation to actually ignore invalid packets or passwords 2023-10-24 11:20:13 +01:00
Hamish Coleman c552db6443 Fix last seen edge case 2023-10-24 11:20:13 +01:00
Hamish Coleman beb14c8d70 Dont treat bools as a magic number and simplify negated tests where possible 2023-10-24 11:20:13 +01:00
Hamish Coleman 1a598fa43b Ensure that we initialise the purgeability of peer structures when we allocate them 2023-10-24 11:20:13 +01:00
Hamish Coleman e9659e3b9a Add a last_seen column to n2n-ctl with human readable values 2023-10-24 11:20:13 +01:00
Hamish Coleman b0d742b3f5 Remove the need for autoconf in the debian package
Continuing to try and simplify the build system, calculate the remaining
two autoconf variables from the existing config.mak.

For the moment, leave a configure and configure.ac file in place to
allow any old build systems to continue to function without errors.
2023-08-30 20:27:14 +01:00
Hamish Coleman 018add0280 Use a simple debian/control Architecture
By switching to the "any" architecture, we no longer need to template
the debian/control file.  This simply claims that the package can be
built on any known debian arch - which we currently think is true - so
it will help future portability.
2023-08-30 20:27:14 +01:00
Hamish Coleman d7eff5313b Add a hack for the github builders 2023-08-30 20:27:14 +01:00
Hamish Coleman 9d4f68fce2 Regenerate packages configure scripts 2023-08-30 20:27:14 +01:00
Hamish Coleman cee0431a61 Work around ubuntu build environment
TODO:
- dont just ignore missing info, have something to fill it in even when
  the require arch binaries are missing
2023-08-30 20:27:14 +01:00
Hamish Coleman f2597e8f42 Install some packages for cross compiling 2023-08-30 20:27:14 +01:00
Hamish Coleman 231f4d9ed0 Remove unneeded debian/files - it is autogenerated 2023-08-30 20:27:14 +01:00
Hamish Coleman 1b862513ff Regenerate packages configure scripts 2023-08-30 20:27:14 +01:00
Hamish Coleman c2f08642c0 Remove unneeded templating of systemd units 2023-08-30 20:27:14 +01:00
Hamish Coleman 50748f210a Remove unneeded templating of debian/rules 2023-08-30 20:27:14 +01:00
Hamish Coleman 0385d4fcbe Automatically generate debian changelog 2023-08-30 20:27:14 +01:00
Hamish Coleman 3cb57e2a6e Use dh_shlibdeps to calculate depends
This may impact builds on Debian 8, but that version has been out of
support for over three years.  I didnt test it, but since using this
helper is the preferred method it may actually help builds on older
versions.
2023-08-30 20:27:14 +01:00
Hamish Coleman ecb869517e Remove static definition from deb package builder 2023-08-30 20:27:14 +01:00
Hamish Coleman f79153166b Concentrate more windows wierdness in one place - allowing proper ordering of crazy defs and includes 2023-08-03 21:40:31 +01:00
Hamish Coleman 65359c7916 Add a missing library function 2023-08-03 21:40:31 +01:00
Hamish Coleman 5514d91976 For some reason, these headers dont work for 64bit - windows is strange 2023-08-03 21:40:31 +01:00
Hamish Coleman 5eaf7fca8b Add windows XP to regular cross-compile tests 2023-08-03 21:40:31 +01:00
Hamish Coleman 567ae8db6b Try to simplify and improve windows objs definitions 2023-08-03 21:40:31 +01:00
Hamish Coleman 3bf584c580 Add tweaks to support windows XP 2023-08-03 21:40:31 +01:00
Hamish Coleman 439939dc7b Simplify tuntap_open by using one function prototype for all OS 2023-08-03 21:40:31 +01:00
Hamish Coleman 6b8ba8aa94 Move the examples to their own directory 2023-07-31 20:56:49 +01:00
Hamish Coleman 6ddaaaa917 Move win32 specific file to the right dir 2023-07-31 20:56:49 +01:00
Hamish Coleman 83078c8104 Simplify win32 build process
When building on win32 systems, simply add the win32 specific functions
to the libn2n.a, which simplifies the commands needed.

By moving the win32 source code into the src directory, the source code
is better consolidated.
2023-07-31 20:56:49 +01:00
Hamish Coleman 6957b16537 Address compiler warning on older gcc 2023-07-06 02:54:36 +08:00
Hamish Coleman 183e0c969a Hack around the "helpful" exe file suffix
If there is a way to turn off the mingw insistence that it will rewrite
the filename it was given in the "-o" options, I have not been able to
find it.  I could easily handle all the moves or renames at the end of
the build process if I could turn off this feature.  Especially since it
means that make often thinks that the file has not been built (the
filename that make knows about is not the file that actually gets built
by the mingw gcc, so the if-newer tests that make applies will always
fail)
2023-07-03 02:51:20 +08:00
Hamish Coleman 84dac6220b Add a cross-compiled 64bit windows build to CI 2023-07-03 02:51:20 +08:00
Hamish Coleman e16911d6ec The arm64 build has now been tested on real hardware 2023-07-03 02:51:20 +08:00
Hamish Coleman 0b662fc0f4 A bunch of hacks to allow builds to understand the stupid windows filenames 2023-07-03 02:51:20 +08:00
Hamish Coleman 4d2e92ac81 Ensure library is included in correct order
It looks to me that the correct way to address this build wrinkle is
simply to add the win32 functions to the libn2n when building a win32
output, then there is no additional magic library juggling required for
the win32 case
2023-07-03 02:51:20 +08:00
Hamish Coleman 1e8a085f1e Refactor to use the host triplet instead of CONFIG_TARGET 2023-07-03 02:51:20 +08:00
Hamish Coleman 59ecadcab2 Move the special windows lib config into the configure script 2023-07-03 02:51:20 +08:00
Hamish Coleman b22c57a16f Dont require special build flags for just one header 2023-07-03 02:51:20 +08:00
Hamish Coleman e79616dc8b Dont include unneeded headers 2023-07-03 02:51:20 +08:00
Hamish Coleman 85c8ab536c Convert final user of TARGET==darwin to use the cross-compile variables instead 2023-07-03 02:51:20 +08:00
Hamish Coleman 4b4311e2fa Move the macos default install path config.
There is a minor change - after this, the macos man pages are also
installed into the /usr/local PREFIX.  This seems like the correct
location to me.

Longer term, the usual autotools process of installing everything into
/usr/local should be used.  Files installed in /usr should be done by
a package management tool, so this default makes sense to use.
2023-07-03 02:51:20 +08:00
Hamish Coleman 15fe4f786f Move OpenSolaris special config to the configure script 2023-07-03 02:51:20 +08:00
Hamish Coleman 8dcc879ca0 Simplify config and build process for libpcap tool 2023-07-02 22:18:09 +08:00
Hamish Coleman 433b14c52f Simplify openssl library detection and macros 2023-07-02 22:18:09 +08:00
Hamish Coleman f05c24b259 Fix openssl support and add it to tests 2023-07-01 19:08:43 +08:00
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 5942726685 Address some windows compile warnings 2023-06-26 00:14:09 +08:00
Hamish Coleman a0c2af5f78 Remove define that no longer does anything 2023-06-25 22:40:46 +08:00
Hamish Coleman afbc5344e0 Move some generic appending out of the config.mak 2023-06-25 22:40:46 +08:00
Hamish Coleman 6d464f24a6 Ensure that WINDRES always has a value 2023-06-25 22:40:46 +08:00
Hamish Coleman 3c9a170b12 Some header simplification 2023-06-25 22:40:46 +08:00
Hamish Coleman d21a4fe0a2 Remove some unneeded includes 2023-06-25 22:40:46 +08:00
Hamish Coleman 548e1204f3 Address warning - another windows pedantic header order issue 2023-06-25 22:40:46 +08:00
Hamish Coleman d39f5c7892 Disable running full tests on BSD builds - they are flappy 2023-06-25 22:19:36 +08:00
Hamish Coleman ce3ed1fb90 Expand the freebsd hacky fix to encompas edge tests as well 2023-06-25 22:19:36 +08:00
Hamish Coleman ccd33dc8cc Hacky fix for tests running on freebsd 2023-06-25 21:08:36 +08:00
Hamish Coleman 0d005d189d Fix silent failure of sizeof for STRBUF_INIT() 2023-06-25 21:08:36 +08:00
Hamish Coleman 42a716ae7b Actually test freebsd 2023-06-25 21:08:36 +08:00
Hamish Coleman a2c78e140a Minor fixes for FreeBSD 2023-06-25 19:25:00 +08:00
Hamish Coleman 2413ce498f The autogen script is not using any bash features 2023-06-25 19:25:00 +08:00
Hamish Coleman 89125ec423 Use the defined access method for structure.
Not all struct sockaddr are going to have the sa_family as their first field.
Since there is a named structure member, we can simply use that and let
the compiler sort it out.

This fixes a bug with at least FreeBSD and allows us to remove the
special case for Apple.
2023-06-25 19:25:00 +08:00
Hamish Coleman 169d3a8cc7 Fix use with older autoconf
Some versions of autoconf (eg, the one included with Ubuntu 20.04 -
which is GNU Autoconf 2.69) will produce a configure script that
requires finding the install-sh script in either a short list of parent
directories or the defined AUX_DIR (This new requirement was probably
triggered by the use of the cross-compile features in configure.ac)

Newer versions flexibly identify which of the support scripts are
actually needed (from the list of config.guess, config.sub, install-sh)
and only check for those ones that are needed.

When the `./autogen.sh` runs `autoreconf -i`, it should have copied the
required aux scripts, but for some reason this is not happening.

Once we are not supporting the older autoconf, we should revisit this
config option as these auxiliary scripts should normally not be checked
into a version control system, for the same reasons that configure
shouldn’t be.  For now, we ensure that all three scripts are available
and we have set the AC_CONFIG_AUX_DIR() to point to them

If the older autoconf is used, it will report the error:

    configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."

Which is included here for search engines.
2023-06-25 17:56:09 +08:00
Hamish Coleman cfc9c8c10d Simplify and make more consistant the pthread library 2023-06-25 17:56:09 +08:00
Hamish Coleman 4c0c173221 Check if we have been configured before running most of Make 2023-06-25 17:56:09 +08:00
Hamish Coleman a1bef636de Partially Revert "Add rules to run autogen/configure and use them in some of the simpler CI builds"
This reverts commit 87c20d750e.
2023-06-25 17:56:09 +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 87c20d750e Add rules to run autogen/configure and use them in some of the simpler CI builds 2023-06-25 02:07:49 +08:00
Hamish Coleman 9417866394 Use the more usual name for autoconf libs variable 2023-06-25 02:07:49 +08:00
Hamish Coleman 4a724c10a2 Dont need to tell configure to subst some vars as they are exported by default 2023-06-25 02:07:49 +08:00
Hamish Coleman 1581b74027 Update everything to reference the simpler tool autodetection 2023-06-25 02:07:49 +08:00
Hamish Coleman 4bbee2c3b5 Use the standard autoconf macros to help with cross-compile 2023-06-25 02:07:49 +08:00
Hamish Coleman 1b83e0e0e9 Remove some config items that are just wrong with cross compilation 2023-06-25 02:07:49 +08:00
Hamish Coleman 3b5855707f Need to specify a windres tool name for non cross compiled windows 2023-06-25 02:07:49 +08:00
Hamish Coleman 0545a54b13 Allow windres to run when cross compiling 2023-06-25 02:07:49 +08:00
Hamish Coleman 0dd94a1123 Fix distclean with newer config.mak style 2023-06-24 23:31:20 +08:00
Hamish Coleman 4f9a7d31d3 Fix bug in returned interface address 2023-06-24 23:31:20 +08:00
Hamish Coleman 7b77950352 Address lint concerns 2023-06-24 23:31:20 +08:00
Hamish Coleman e8c7457b80 Fix null pointer de-ref 2023-06-24 23:31:20 +08:00
Hamish ColemanandGitHub b5a8210efd Merge pull request #1119 from hamishcoleman/iwyu
Refactor to "include-what-you-use"

This patchset aims to make future refactoring and cleanups simpler by ensuring that each file includes what it uses - see https://include-what-you-use.org/ for some more details about this concept and the tool used to help perform the refactoring.

No functional change is intended or expected and all tests are passing.

The include-what-you-use tool is awkward to use with the current state of the build system - and will always be difficult to use in a multi-platform safe way. However, I hope to provide a non manual process for running with the tool in the future.
2023-06-20 19:49:16 +01:00
Hamish Coleman a7fc1c2bbc Merge branch 'dev' into iwyu 2023-06-18 12:31:58 +01:00
Hamish Coleman 585b3cec59 iwyu: n2n.h
There is still cleanup work to be done in the headers, but this
concludes the major include-what-you-use refactoring.  No functional
change is intended or expected and all tests are passing.

It is now a lot easier to see what is used from each header and work on
possible refactoring in the future.

The include-what-you-use tool is awkward to use with the current state
of the build system - and will always be difficult to use in a
multi-platform safe way.  However, I hope to provide a non manual
process for running with the tool in the future.
2023-06-18 12:14:23 +01:00
Hamish Coleman 771fdec013 iwyu: tools/test*.c 2023-06-18 11:34:28 +01:00
Hamish Coleman 0a20265228 iwyu: n2n-route.c 2023-06-18 11:14:47 +01:00
Hamish Coleman 290ac83788 iwyu: n2n-portfwd.c 2023-06-18 10:58:00 +01:00
Hamish Coleman 7439d88a00 iwyu: n2n-keygen.c 2023-06-18 10:56:05 +01:00
Hamish Coleman 11fbea4223 iwyu: n2n-benchmark.c 2023-06-18 10:55:07 +01:00
Hamish Coleman b9dcb3fd35 iwyu: wire.c 2023-06-18 09:32:08 +01:00
Hamish Coleman de56ebb127 iwyu: tuntap_linux.c 2023-06-18 09:12:36 +01:00
Hamish Coleman 852fc6ea8f Minimal update to transform_zstd suggested by iwyu.
This file was not active during the iwyu run, so it will need to be
expanded upon later.
2023-06-16 11:05:35 +01:00
Hamish Coleman 3e47641630 Actually test the zstd support before editing the transform_zstd 2023-06-16 09:56:53 +01:00
Hamish Coleman 0e175d35f6 iwyu: transform_tf.c 2023-06-16 09:44:53 +01:00
Hamish Coleman 76629dcf6a iwyu: transform_speck.c 2023-06-16 09:44:04 +01:00
Hamish Coleman 6deebe6f1a iwyu: transform_null.c 2023-06-16 09:43:02 +01:00
Hamish Coleman 89cb9419c7 iwyu: transform_lzo.c 2023-06-16 09:42:18 +01:00
Hamish Coleman 8b6fcb8ab6 iwyu: transform_cc20.c 2023-06-16 09:41:08 +01:00
Hamish Coleman 8443c29428 iwyu: transform_aes.c 2023-06-16 09:40:16 +01:00
Hamish Coleman fa4cf74ff2 iwyu: supernode.c 2023-06-16 09:33:52 +01:00
Hamish Coleman 6ee14559f9 iwyu: sn_utils.c 2023-06-16 09:26:04 +01:00
Hamish Coleman a8356c93db iwyu: sn_selection.c 2023-06-16 09:19:39 +01:00