Browse Source

manual merge crashey

Caleb James DeLisle 2 years ago
parent
commit
7ba35479e7
60 changed files with 359 additions and 208 deletions
  1. 0 14
      Cargo.lock
  2. 1 6
      Cargo.toml
  3. 4 7
      README.md
  4. 1 0
      README_DE.md
  5. 3 2
      README_ES.md
  6. 2 1
      README_FR.md
  7. 105 1
      README_GR.md
  8. 5 1
      README_HR.md
  9. 4 4
      README_PT-BR.md
  10. 6 2
      README_RU.md
  11. 4 1
      README_SV.md
  12. 3 2
      README_ZHT.md
  13. 5 5
      admin/Admin.c
  14. 1 1
      admin/AdminLog.c
  15. 1 1
      android_do
  16. 1 1
      contrib/simple-install/README.md
  17. 1 0
      contrib/simple-install/cjdns-installer.sh
  18. 3 3
      crypto/CryptoAuth.c
  19. 4 4
      dht/dhtcore/Janitor.c
  20. 6 6
      dht/dhtcore/NodeStore.c
  21. 1 1
      dht/dhtcore/RouterModule.c
  22. 4 4
      doc/Whitepaper.md
  23. 6 0
      doc/nat-gateway.md
  24. 10 10
      net/InterfaceController.c
  25. 7 7
      net/SessionManager.c
  26. 1 1
      node_build/CjdnsTest.js
  27. 14 5
      node_build/builder.js
  28. 1 1
      node_build/run_jshint
  29. 24 0
      rust/cjdns_sys/Rffi.h
  30. 0 0
      rust/cjdns_sys/src/bin/cjdroute.rs
  31. 0 0
      rust/cjdns_sys/src/bin/makekeys.rs
  32. 0 0
      rust/cjdns_sys/src/bin/mkpasswd.rs
  33. 0 0
      rust/cjdns_sys/src/bin/privatetopublic.rs
  34. 0 0
      rust/cjdns_sys/src/bin/publictoip6.rs
  35. 0 0
      rust/cjdns_sys/src/bin/randombytes.rs
  36. 0 0
      rust/cjdns_sys/src/bin/sybilsim.rs
  37. 0 0
      rust/cjdns_sys/src/bin/testcjdroute.rs
  38. 1 0
      rust/cjdns_sys/src/interface/wire/message.rs
  39. 80 4
      rust/cjdns_sys/src/rffi.rs
  40. 0 10
      rust/cjdroute/Cargo.toml
  41. 0 10
      rust/makekeys/Cargo.toml
  42. 0 10
      rust/mkpasswd/Cargo.toml
  43. 0 10
      rust/privatetopublic/Cargo.toml
  44. 0 10
      rust/publictoip6/Cargo.toml
  45. 0 10
      rust/randombytes/Cargo.toml
  46. 0 10
      rust/sybilsim/Cargo.toml
  47. 0 10
      rust/testcjdroute/Cargo.toml
  48. 1 1
      subnode/ReachabilityAnnouncer.c
  49. 1 1
      subnode/ReachabilityCollector.c
  50. 4 4
      subnode/SupernodeHunter.c
  51. 2 2
      test/BeaconFramework.c
  52. 2 2
      test/Main_fuzz_test.c
  53. 1 1
      util/ArrayList.h
  54. 2 2
      util/AverageRoller.c
  55. 3 3
      util/Pinger.c
  56. 1 1
      util/Set.h
  57. 2 3
      util/events/Time.h
  58. 6 7
      util/events/libuv/Time.c
  59. 19 1
      util/events/libuv/libuv.js
  60. 6 5
      util/platform/Sockaddr.c

+ 0 - 14
Cargo.lock

@@ -261,13 +261,6 @@ dependencies = [
  "thiserror",
  "thiserror",
 ]
 ]
 
 
-[[package]]
-name = "cjdroute"
-version = "0.1.0"
-dependencies = [
- "cjdns_sys",
-]
-
 [[package]]
 [[package]]
 name = "clang-sys"
 name = "clang-sys"
 version = "1.0.3"
 version = "1.0.3"
@@ -1003,13 +996,6 @@ dependencies = [
  "winapi-util",
  "winapi-util",
 ]
 ]
 
 
-[[package]]
-name = "testcjdroute"
-version = "0.1.0"
-dependencies = [
- "cjdns_sys",
-]
-
 [[package]]
 [[package]]
 name = "textwrap"
 name = "textwrap"
 version = "0.11.0"
 version = "0.11.0"

+ 1 - 6
Cargo.toml

@@ -1,10 +1,5 @@
 [workspace]
 [workspace]
-
-members = [
-    "rust/cjdns_sys",
-    "rust/cjdroute",
-    "rust/testcjdroute",
-]
+members = ["rust/cjdns_sys"]
 
 
 [profile.release]
 [profile.release]
 lto = true
 lto = true

+ 4 - 7
README.md

@@ -52,7 +52,7 @@ scalability issues that plague existing networks.
 
 
 ## Community
 ## Community
 
 
-* [irc://irc.freenode.org/#cjdns][IRC Web]
+* [irc://irc.efnet.org/#cjdns][IRC Web]
 * [Hyperboria][] the largest cjdns network, as of October 2015 there are 2100 nodes.
 * [Hyperboria][] the largest cjdns network, as of October 2015 there are 2100 nodes.
 * [/r/darknetplan][]
 * [/r/darknetplan][]
 * [#cjdns on Twitter][]
 * [#cjdns on Twitter][]
@@ -137,7 +137,7 @@ If you need to build from source, everything you need can be installed like this
     pacman -S nodejs git base-devel
     pacman -S nodejs git base-devel
 
 
 Alternatively, you may like to install via AUR from the package, `cjdns-git`.
 Alternatively, you may like to install via AUR from the package, `cjdns-git`.
-After Installation, The configuration file is located at `/etc/cjdroute.conf`.
+After installation, the configuration file is located at `/etc/cjdroute.conf`.
 To start the service `cjdns.service`, do:
 To start the service `cjdns.service`, do:
 
 
     systemctl start cjdns
     systemctl start cjdns
@@ -224,14 +224,14 @@ Then Follow the steps below:
 
 
 *Sorry for so many steps. A package is being worked on currently*
 *Sorry for so many steps. A package is being worked on currently*
 
 
-##### 1. Retrieve cjdns from GitHub
+### 1. Retrieve cjdns from GitHub
 
 
 Clone the repository from GitHub and change to the source directory:
 Clone the repository from GitHub and change to the source directory:
 
 
     git clone https://github.com/cjdelisle/cjdns.git cjdns
     git clone https://github.com/cjdelisle/cjdns.git cjdns
     cd cjdns
     cd cjdns
 
 
-##### 2. Build
+### 2. Build
 
 
     ./do
     ./do
 
 
@@ -495,9 +495,6 @@ full disclosure.
 See: [security_specification.md](https://github.com/cjdelisle/cjdns/blob/master/doc/security_specification.md) to see if a
 See: [security_specification.md](https://github.com/cjdelisle/cjdns/blob/master/doc/security_specification.md) to see if a
 possible security issue is really a security issue.
 possible security issue is really a security issue.
 
 
-That time of year again... Time for some open source Projects!
-[![Hacktoberfest](https://img.shields.io/badge/Open%20Source-Hacktoberfest-orange.svg)](https://hacktoberfest.digitalocean.com/)
-
 [IRC Web]: http://chat.efnet.org/irc.cgi?chan=%23cjdns
 [IRC Web]: http://chat.efnet.org/irc.cgi?chan=%23cjdns
 [Hyperboria]: https://hyperboria.net
 [Hyperboria]: https://hyperboria.net
 [/r/darknetplan]: https://www.reddit.com/r/darknetplan
 [/r/darknetplan]: https://www.reddit.com/r/darknetplan

+ 1 - 0
README_DE.md

@@ -8,6 +8,7 @@
 [繁體中文](README_ZHT.md)
 [繁體中文](README_ZHT.md)
 [Español](README_ES.md)
 [Español](README_ES.md)
 [Français](README_FR.md)
 [Français](README_FR.md)
+[Português brasileiro](README_PT-BR.md)
 
 
 #### *Netzwerk neu erfunden*
 #### *Netzwerk neu erfunden*
 
 

+ 3 - 2
README_ES.md

@@ -1,13 +1,14 @@
 # cjdns
 # cjdns
 
 
+[English](README.md)
 [Русская версия](README_RU.md)
 [Русская версия](README_RU.md)
 [Hrvatski](README_HR.md)
 [Hrvatski](README_HR.md)
 [Svenska](README_SV.md)
 [Svenska](README_SV.md)
 [Ελληνικά](README_GR.md)
 [Ελληνικά](README_GR.md)
 [Deutsch](README_DE.md)
 [Deutsch](README_DE.md)
 [繁體中文](README_ZHT.md)
 [繁體中文](README_ZHT.md)
-[Español](README_ES.md)
 [Français](README_FR.md)
 [Français](README_FR.md)
+[Português brasileiro](README_PT-BR.md)
 
 
 #### *Reinventando las redes*
 #### *Reinventando las redes*
 
 
@@ -16,7 +17,7 @@ la asignación de direcciones y una tabla distribuida de hashes para el
 ruteo. Esto provee redes de casi-nula-configuración, y previene mucho de los
 ruteo. Esto provee redes de casi-nula-configuración, y previene mucho de los
 problemas de seguridad y escalabilidad que plagan a las redes existentes.
 problemas de seguridad y escalabilidad que plagan a las redes existentes.
 
 
-[![Build Status](https://travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
+[![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
 [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/387/badge)](https://bestpractices.coreinfrastructure.org/projects/387)
 [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/387/badge)](https://bestpractices.coreinfrastructure.org/projects/387)
 [![tip for next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
 [![tip for next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
 [![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
 [![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)

+ 2 - 1
README_FR.md

@@ -2,6 +2,7 @@ Traduction à partir de la version
 [`cjdns-v19.1`](https://github.com/woshilapin/cjdns/blob/cjdns-v19.1/README.md)
 [`cjdns-v19.1`](https://github.com/woshilapin/cjdns/blob/cjdns-v19.1/README.md)
 # cjdns
 # cjdns
 
 
+[English](README.md)
 [Русская версия](README_RU.md)
 [Русская версия](README_RU.md)
 [Hrvatski](README_HR.md)
 [Hrvatski](README_HR.md)
 [Svenska](README_SV.md)
 [Svenska](README_SV.md)
@@ -9,7 +10,7 @@ Traduction à partir de la version
 [Deutsch](README_DE.md)
 [Deutsch](README_DE.md)
 [繁體中文](README_ZHT.md)
 [繁體中文](README_ZHT.md)
 [Español](README_ES.md)
 [Español](README_ES.md)
-[Français](README_FR.md)
+[Português brasileiro](README_PT-BR.md)
 
 
 #### *Le réseau réinventé*
 #### *Le réseau réinventé*
 
 

+ 105 - 1
README_GR.md

@@ -8,6 +8,7 @@
 [繁體中文](README_ZHT.md)
 [繁體中文](README_ZHT.md)
 [Español](README_ES.md)
 [Español](README_ES.md)
 [Français](README_FR.md)
 [Français](README_FR.md)
+[Português brasileiro](README_PT-BR.md)
 
 
 #### *Η δικτύωση επανεφευρέθηκε*
 #### *Η δικτύωση επανεφευρέθηκε*
 
 
@@ -17,8 +18,10 @@ Cjdns υλοποιεί ένα κρυπτογραφημένο δίκτυο IPV6 
 επεκτασιμότητας που μαστίζουν τα υπάρχοντα δίκτυα.
 επεκτασιμότητας που μαστίζουν τα υπάρχοντα δίκτυα.
 
 
 [![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
 [![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
+[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/387/badge)](https://bestpractices.coreinfrastructure.org/projects/387)
 [![tip for next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
 [![tip for next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
 [![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
 [![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
+![License](https://img.shields.io/github/license/cjdelisle/cjdns.svg)
 
 
 ## Γνώμες πελατών
 ## Γνώμες πελατών
 
 
@@ -127,11 +130,99 @@ Cjdns υλοποιεί ένα κρυπτογραφημένο δίκτυο IPV6 
 
 
     pacman -S nodejs git base-devel
     pacman -S nodejs git base-devel
 
 
+Εναλλακτικά, μπορείτε να το εγκαταστήσετε μέσω του AUR από το πακέτο, `cjdns-git`.
+Μετά την εγκατάσταση, το αρχείο ρυθμίσεων βρίσκεται στην τοποθεσία `/etc/cjdroute.conf`.
+Για να ξεκινήσετε το service `cjdns.service`, κάντε:
+
+    systemctl start cjdns
+
+Για να το σταματήσετε:
+
+    systemctl stop cjdns
+
+#### Gentoo:
+
+Το cjdns δεν βρίσκεται ακόμα στο κύριο εναποθετήριο του Gentoo, οπότε θα χρειαστεί να χρησιμοποιήσετε το ένα overlay.
+Ο ευκολότερος τρόπος είναι να χρησιμοποιήσετε το Layman αλλά μπορείτε και χειροκίνητα επίσης.
+
+##### Layman:
+
+Πρώτα, θα χρειαστεί να εγκαταστήσετε το layman.
+
+    emerge layman
+
+Αν το layman εγκαταστάθηκε σωστά, μπορείτε να προσθέσετε το overlay
+
+    layman -f
+    layman -a weuxel
+
+Για μελλοντικές αναβαθμίσεις του overlay χρησιμοποιήστε
+
+    layman -S
+
+Τώρα μπορείτε να εγκαταστήσετε το cjdns
+
+    emerge cjdns
+
+##### Χειροκίνητα:
+
+Κλωνοποιήστε το εναποθετήριο του overlay
+
+    cd /opt
+    git clone https://github.com/Weuxel/portage-weuxel.git
+
+Πείτε στο portage να χρησιμοποιήσει το εναποθετήριο
+
+    cd /etc/portage/repos.conf/
+
+Δημιουργήστε ένα αρχείο με όνομα `portage-weuxel.conf` που να περιέχει
+
+    [weuxel]
+    location = /opt/portage-weuxel
+    masters = gentoo
+    auto-sync = yes
+
+Τώρα συγχρονίστε
+
+    emerge --sync
+
+Και εγκαταστήστε το cjdns
+
+    emerge cjdns
+
+#### Αυτόματος έλεγχος διακοπής λειτουργίας και επανεκκίνηση
+
+Αντιγράψτε το openrc init script από `contrib/openrc` στο φάκελο `/etc/init.d/` και αλλάξτε τις παραμέτρους `CONFFILE` και `command` σύμφωνα με τις ανάγκες σας.
+Μετά ξεκινήστε το cjdns πληκτρολογώντας
+
+    /etc/init.d/cjdns start
+
+Ρυθμίστε το init system ώστε να ξεκινά το cjdns αυτόματα
+
+    rc-update add cjdns default
+
+Αντιγράψτε το service_restart script `contrib/gentoo/service_restart.sh` σε οποιονδήποτε φάκελο πιστεύτε πως θα έπρεπε να βρίσκεται στο
+σύστημά σας και αλλάξτε τη διεύθυνση eMail. Αν δε θέλετε να ειδοποιήστε, μαρκάρετε τη γραμμή ως σχόλιο.
+Τώρα προσθέστε μια εγγραφή στο crontab με αυτό τον τρόπο
+
+    # Restart crashed Services
+    * * * * *       root    /path/to/script/service_restart.sh
+
+#### Solus:
+
+Εξαρτήσεις:
+
+    sudo eopkg install nodejs git build-essential system.devel python gcc binutils kernal-headers xorg-server-devel
+
+Ακολουθήστε τα βήματα παρακάτω:
+
+*Ζητούμε συγγνώμη για τα τόσα πολλά βήματα. Προετοιμάζεται ένα πακέτο*
+
 ### 1. Ανακτήστε το cjdns από το GitHub
 ### 1. Ανακτήστε το cjdns από το GitHub
 
 
 Κλωνοποίηστε το αποθετήριο από το GitHub και περάστε στο πηγαίο φάκελο:
 Κλωνοποίηστε το αποθετήριο από το GitHub και περάστε στο πηγαίο φάκελο:
 
 
-    git clone https://github.com/cjdelisle/cjdns.git
+    git clone https://github.com/cjdelisle/cjdns.git cjdns
     cd cjdns
     cd cjdns
 
 
 ### 2. Χτίστε
 ### 2. Χτίστε
@@ -373,6 +464,19 @@ TUN/TAP συσκευή - αυτό είναι στάνταρ πρωτόκολλο
 * την **Python library**; δείτε [εδώ](contrib/python/README.md).
 * την **Python library**; δείτε [εδώ](contrib/python/README.md).
 * την **Perl library**, συντηρείται από τον Mikey; δείτε [εδώ](contrib/perl/CJDNS/README).
 * την **Perl library**, συντηρείται από τον Mikey; δείτε [εδώ](contrib/perl/CJDNS/README).
 
 
+## Αναφορά προβλημάτων
+1. Μην αναφέρετε σε αυτό το εναποθετήριο, αντ' αυτού παρακαλούμε αναφέρετέ το στο https://github.com/hyperboria/bugs/issues
+2. Μπείτε στο IRC και μιλήστε με κάποιο
+3. Το τι μπορεί να συμβεί είναι είτε
+ * κάποιος μπορεί να το φτιάξει
+ * εσείς μπορείτε να το φτιάξετε
+ * κανείς δεν ασχολείτε και παραμένει ξεχασμένο μέχρι κάποιος να πέσει πάνω του αργότερα και το φτιάξει ή απλά θα χαθεί σε κάποιο ανασχεδιασμό
+ * κανείς δε μπορεί να το φτιάξει εκείνη τη στιγμή αλλά είναι σημαντικό να το θυμόμαστε γιατί έχει μεγάλη σημασία στον τρόπο που δημιουργείται ο κώδικας, σε αυτή την περίπτωση χρειάζεται να εξηγηθεί με τεχνικούς όρους από κάποιον που είναι οικείος με τον κώδικα. Μπορούν να κάνουν κάποιο pull request στο φάκελο docs/bugs.
+
+### Ασφάλεια
+Τα προβλήματα ασφαλείας θα πρέπει να αναφέρονται στο IRC όπως και τα υπόλοιπα bugs. Δεν έχουμε κάποιο κλειστό group ανθρώπων με εξειδικευμένη γνώση οπότε αυτό σημαίνει πως η προεπιλεγμένη μέθοδος αναφοράς προβλημάτων ασφαλείας είναι η πλήρης περιγραφή.
+
+Δείτε: [security_specification.md](https://github.com/cjdelisle/cjdns/blob/master/doc/security_specification.md) ώστε να καταλάβετε αν ένα πιθανό πρόβλημα ασφάλεια είναι πραγματικά πρόβλημα ασφάλειας.
 
 
 [IRC Web]: http://chat.efnet.org/irc.cgi?chan=%23cjdns
 [IRC Web]: http://chat.efnet.org/irc.cgi?chan=%23cjdns
 [Hyperboria]: https://hyperboria.net
 [Hyperboria]: https://hyperboria.net

+ 5 - 1
README_HR.md

@@ -8,6 +8,7 @@
 [繁體中文](README_ZHT.md)
 [繁體中文](README_ZHT.md)
 [Español](README_ES.md)
 [Español](README_ES.md)
 [Français](README_FR.md)
 [Français](README_FR.md)
+[Português brasileiro](README_PT-BR.md)
 
 
 #### *Umrežavanje iznova*
 #### *Umrežavanje iznova*
 
 
@@ -17,7 +18,10 @@ mrežnu konfiguraciju i sprječava mnoge sigurnosne i
 skalabilne probleme koje muče trenutne mreže.
 skalabilne probleme koje muče trenutne mreže.
 
 
 [![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
 [![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
+[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/387/badge)](https://bestpractices.coreinfrastructure.org/projects/387)
 [![napojnica za sljedeću promjenu](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
 [![napojnica za sljedeću promjenu](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
+[![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
+![License](https://img.shields.io/github/license/cjdelisle/cjdns.svg)
 
 
 ## Iskustva
 ## Iskustva
 
 
@@ -38,7 +42,7 @@ skalabilne probleme koje muče trenutne mreže.
 
 
 ## Zajednica
 ## Zajednica
 
 
-* irc://irc.efnet.org/#cjdns ([web client][IRC Web])
+* [irc://irc.efnet.org/#cjdns][IRC Web]
 * [Hyperboria][]
 * [Hyperboria][]
 * [Projekt Meshnet][]
 * [Projekt Meshnet][]
 * [/r/darknetplan][]
 * [/r/darknetplan][]

+ 4 - 4
README_PT-BR.md

@@ -1,5 +1,6 @@
 # cjdns
 # cjdns
 
 
+[English](README.md)
 [Русская версия](README_RU.md)
 [Русская версия](README_RU.md)
 [Hrvatski](README_HR.md)
 [Hrvatski](README_HR.md)
 [Svenska](README_SV.md)
 [Svenska](README_SV.md)
@@ -8,13 +9,12 @@
 [繁體中文](README_ZHT.md)
 [繁體中文](README_ZHT.md)
 [Español](README_ES.md)
 [Español](README_ES.md)
 [Français](README_FR.md)
 [Français](README_FR.md)
-[Português brasileiro](README_PT-BR.md)
 
 
-#### *Rede Reinventada*
+#### *Networking Reinventada*
 
 
 O Cjdns implementa uma rede IPv6 criptografada usando criptografia de chave pública para
 O Cjdns implementa uma rede IPv6 criptografada usando criptografia de chave pública para
 alocação de endereços e uma tabela de hash distribuída para roteamento. Isso fornece
 alocação de endereços e uma tabela de hash distribuída para roteamento. Isso fornece
-rede de configuração quase zero e evita muitos dos aspectos de segurança e
+configuração de rede quase zero e evita muitos dos aspectos de segurança e
 problemas de escalabilidade que afetam as redes existentes.
 problemas de escalabilidade que afetam as redes existentes.
 
 
 [![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
 [![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
@@ -63,7 +63,7 @@ problemas de escalabilidade que afetam as redes existentes.
 
 
 * [Objetivos do projeto](doc/projectGoals.md)
 * [Objetivos do projeto](doc/projectGoals.md)
 * [Cjdns Whitepaper](doc/Whitepaper.md)
 * [Cjdns Whitepaper](doc/Whitepaper.md)
-* [Cjdns na Wikipedia][]
+* [Cjdns na Wikipedia](https://fr.wikipedia.org/wiki/Cjdns)
 
 
 Configuração avançada:
 Configuração avançada:
 
 

+ 6 - 2
README_RU.md

@@ -8,13 +8,17 @@
 [繁體中文](README_ZHT.md)
 [繁體中文](README_ZHT.md)
 [Español](README_ES.md)
 [Español](README_ES.md)
 [Français](README_FR.md)
 [Français](README_FR.md)
+[Português brasileiro](README_PT-BR.md)
 
 
 Безопасная, зашифрованная сеть для обычных людей.
 Безопасная, зашифрованная сеть для обычных людей.
 
 
 Cjdns — это зашифрованная IPv6 сеть, в которой используются публичные ключи шифрования для присвоения публичного адреса и распределённой таблицы маршрутизации (DHT). Это позволяет создавать сети с очень простой настройкой, которые будут защищены от потенциальных проблем ныне существующих IPv4 и IPv6 сетей.
 Cjdns — это зашифрованная IPv6 сеть, в которой используются публичные ключи шифрования для присвоения публичного адреса и распределённой таблицы маршрутизации (DHT). Это позволяет создавать сети с очень простой настройкой, которые будут защищены от потенциальных проблем ныне существующих IPv4 и IPv6 сетей.
 
 
-[![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.png?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
-[![For next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
+[![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
+[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/387/badge)](https://bestpractices.coreinfrastructure.org/projects/387)
+[![tip for next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
+[![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
+![License](https://img.shields.io/github/license/cjdelisle/cjdns.svg)
 
 
 ## Рекомендательные письма
 ## Рекомендательные письма
 
 

+ 4 - 1
README_SV.md

@@ -8,6 +8,7 @@
 [繁體中文](README_ZHT.md)
 [繁體中文](README_ZHT.md)
 [Español](README_ES.md)
 [Español](README_ES.md)
 [Français](README_FR.md)
 [Français](README_FR.md)
+[Português brasileiro](README_PT-BR.md)
 
 
 #### *Datornätverk - Ett nytt sätt*
 #### *Datornätverk - Ett nytt sätt*
 
 
@@ -17,9 +18,11 @@ hashtabell (DHT, eller Distributed Hash Table på engelska). Genom denna design
 uppnås ett nätverk som knappt kräver någon konfiguration. Vi blir också av med
 uppnås ett nätverk som knappt kräver någon konfiguration. Vi blir också av med
 många skalnings- och säkerhetsproblem som andra nätverk har.
 många skalnings- och säkerhetsproblem som andra nätverk har.
 
 
-[![Build Status](https://travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
+[![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
+[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/387/badge)](https://bestpractices.coreinfrastructure.org/projects/387)
 [![tip for next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
 [![tip for next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
 [![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
 [![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
+![License](https://img.shields.io/github/license/cjdelisle/cjdns.svg)
 
 
 ## Vitsord
 ## Vitsord
 
 

+ 3 - 2
README_ZHT.md

@@ -1,4 +1,3 @@
-
 # cjdns
 # cjdns
 
 
 [English](README.md)
 [English](README.md)
@@ -9,15 +8,17 @@
 [Deutsch](README_DE.md)
 [Deutsch](README_DE.md)
 [Español](README_ES.md)
 [Español](README_ES.md)
 [Français](README_FR.md)
 [Français](README_FR.md)
+[Português brasileiro](README_PT-BR.md)
 
 
 #### *重朔整個網路*
 #### *重朔整個網路*
 
 
 Cjdns 利用「加密的IPv6」及「公鑰加密」來分配網路地址並利用「Distributed Hash Table」逕行路由。它能提供近似「零配置網路(Zero-Configuration Networking)」,並且能防範在現有網路中存在的很多和安全、可擴展性相關的問題。
 Cjdns 利用「加密的IPv6」及「公鑰加密」來分配網路地址並利用「Distributed Hash Table」逕行路由。它能提供近似「零配置網路(Zero-Configuration Networking)」,並且能防範在現有網路中存在的很多和安全、可擴展性相關的問題。
 
 
-[![Build Status](https://travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
+[![Build Status](https://api.travis-ci.org/cjdelisle/cjdns.svg?branch=master)](https://travis-ci.org/cjdelisle/cjdns)
 [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/387/badge)](https://bestpractices.coreinfrastructure.org/projects/387)
 [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/387/badge)](https://bestpractices.coreinfrastructure.org/projects/387)
 [![tip for next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
 [![tip for next commit](https://tip4commit.com/projects/941.svg)](https://tip4commit.com/github/cjdelisle/cjdns)
 [![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
 [![irc](https://img.shields.io/badge/irc%20chat-%23cjdns-blue.svg)](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
+![License](https://img.shields.io/github/license/cjdelisle/cjdns.svg)
 
 
 ## 評價
 ## 評價
 
 

+ 5 - 5
admin/Admin.c

@@ -157,7 +157,7 @@ static int checkAddress(struct Admin_pvt* admin, int index, uint64_t now)
 static void clearExpiredAddresses(void* vAdmin)
 static void clearExpiredAddresses(void* vAdmin)
 {
 {
     struct Admin_pvt* admin = Identity_check((struct Admin_pvt*) vAdmin);
     struct Admin_pvt* admin = Identity_check((struct Admin_pvt*) vAdmin);
-    uint64_t now = Time_currentTimeMilliseconds(admin->eventBase);
+    uint64_t now = Time_currentTimeMilliseconds();
     int count = 0;
     int count = 0;
     for (int i = admin->map.count - 1; i >= 0; i--) {
     for (int i = admin->map.count - 1; i >= 0; i--) {
         if (checkAddress(admin, i, now)) {
         if (checkAddress(admin, i, now)) {
@@ -191,7 +191,7 @@ static int sendMessage0(Dict* message, String* txid, struct Admin* adminPub, int
     // out forever after a disconnection.
     // out forever after a disconnection.
     if (!admin->currentRequest) {
     if (!admin->currentRequest) {
         int index = Map_LastMessageTimeByAddr_indexForKey(&addr, &admin->map);
         int index = Map_LastMessageTimeByAddr_indexForKey(&addr, &admin->map);
-        uint64_t now = Time_currentTimeMilliseconds(admin->eventBase);
+        uint64_t now = Time_currentTimeMilliseconds();
         if (index < 0 || checkAddress(admin, index, now)) {
         if (index < 0 || checkAddress(admin, index, now)) {
             return Admin_sendMessage_CHANNEL_CLOSED;
             return Admin_sendMessage_CHANNEL_CLOSED;
         }
         }
@@ -228,7 +228,7 @@ static inline bool authValid(Dict* message, struct Message* messageBytes, struct
         int64_t* cookieInt = Dict_getIntC(message, "cookie");
         int64_t* cookieInt = Dict_getIntC(message, "cookie");
         cookie = (cookieInt) ? *cookieInt : 0;
         cookie = (cookieInt) ? *cookieInt : 0;
     }
     }
-    uint64_t nowSecs = Time_currentTimeSeconds(admin->eventBase);
+    uint64_t nowSecs = Time_currentTimeSeconds();
     String* submittedHash = Dict_getStringC(message, "hash");
     String* submittedHash = Dict_getStringC(message, "hash");
     if (cookie >  nowSecs || cookie < nowSecs - 20 || !submittedHash || submittedHash->len != 64) {
     if (cookie >  nowSecs || cookie < nowSecs - 20 || !submittedHash || submittedHash->len != 64) {
         return false;
         return false;
@@ -345,7 +345,7 @@ static void handleRequest(Dict* messageDict,
         //Log_debug(admin->logger, "Got a request for a cookie");
         //Log_debug(admin->logger, "Got a request for a cookie");
         Dict* d = Dict_new(allocator);
         Dict* d = Dict_new(allocator);
         char bytes[32];
         char bytes[32];
-        snprintf(bytes, 32, "%u", (uint32_t) Time_currentTimeSeconds(admin->eventBase));
+        snprintf(bytes, 32, "%u", (uint32_t) Time_currentTimeSeconds());
         String* theCookie = &(String) { .len = CString_strlen(bytes), .bytes = bytes };
         String* theCookie = &(String) { .len = CString_strlen(bytes), .bytes = bytes };
         Dict_putString(d, cookie, theCookie, allocator);
         Dict_putString(d, cookie, theCookie, allocator);
         Admin_sendMessage(d, txid, &admin->pub);
         Admin_sendMessage(d, txid, &admin->pub);
@@ -374,7 +374,7 @@ static void handleRequest(Dict* messageDict,
     // Then sent a valid authed query, lets track their address so they can receive
     // Then sent a valid authed query, lets track their address so they can receive
     // asynchronous messages.
     // asynchronous messages.
     int index = Map_LastMessageTimeByAddr_indexForKey(&src, &admin->map);
     int index = Map_LastMessageTimeByAddr_indexForKey(&src, &admin->map);
-    uint64_t now = Time_currentTimeMilliseconds(admin->eventBase);
+    uint64_t now = Time_currentTimeMilliseconds();
     admin->asyncEnabled = 1;
     admin->asyncEnabled = 1;
     if (index >= 0) {
     if (index >= 0) {
         admin->map.values[index]->timeOfLastMessage = now;
         admin->map.values[index]->timeOfLastMessage = now;

+ 1 - 1
admin/AdminLog.c

@@ -123,7 +123,7 @@ static Dict* makeLogMessage(struct Subscription* subscription,
                             String* message,
                             String* message,
                             struct Allocator* alloc)
                             struct Allocator* alloc)
 {
 {
-    int64_t now = (int64_t) Time_currentTimeSeconds(logger->base);
+    int64_t now = (int64_t) Time_currentTimeSeconds();
 
 
     Dict* out = Dict_new(alloc);
     Dict* out = Dict_new(alloc);
 
 

+ 1 - 1
android_do

@@ -147,5 +147,5 @@ for i in $(seq 1 100); do
   export CARGO_TARGET_ARMV7A_LINUX_ANDROIDEABI_LINKER=$CC
   export CARGO_TARGET_ARMV7A_LINUX_ANDROIDEABI_LINKER=$CC
 
 
   echo "Compiler CC: $CC - $(${CC} --version)"
   echo "Compiler CC: $CC - $(${CC} --version)"
-  cargo build --release -vv --target "$RUST_TARGET"
+  cargo build --release -v --target "$RUST_TARGET"
 done
 done

+ 1 - 1
contrib/simple-install/README.md

@@ -6,7 +6,7 @@ Tested on ubuntu 18.04LTS
 git clone https://github.com/cjdelisle/cjdns.git
 git clone https://github.com/cjdelisle/cjdns.git
 cd cjdns/
 cd cjdns/
 ./do
 ./do
-sudo ./contrib/simple-install/cjdns-install.sh
+sudo ./contrib/simple-install/cjdns-installer.sh
 ```
 ```
 
 
 You can edit configuration in `/etc/cjdroute.conf` and restart cjdns service with `sudo systemctl restart cjdns.service`.
 You can edit configuration in `/etc/cjdroute.conf` and restart cjdns service with `sudo systemctl restart cjdns.service`.

+ 1 - 0
contrib/simple-install/cjdns-installer.sh

@@ -7,4 +7,5 @@ cp publictoip6 /usr/bin/
 cp randombytes /usr/bin/
 cp randombytes /usr/bin/
 cp sybilsim /usr/bin/
 cp sybilsim /usr/bin/
 cp contrib/systemd/cjdns.service /etc/systemd/system/
 cp contrib/systemd/cjdns.service /etc/systemd/system/
+cp contrib/systemd/cjdns-resume.service /etc/systemd/system
 systemctl enable --now cjdns.service
 systemctl enable --now cjdns.service

+ 3 - 3
crypto/CryptoAuth.c

@@ -325,7 +325,7 @@ static void resetIfTimeout(struct CryptoAuth_Session_pvt* session)
         return;
         return;
     }
     }
 
 
-    uint64_t nowSecs = Time_currentTimeSeconds(session->context->eventBase);
+    uint64_t nowSecs = Time_currentTimeSeconds();
     if (nowSecs - session->timeOfLastPacket < session->setupResetAfterInactivitySeconds) {
     if (nowSecs - session->timeOfLastPacket < session->setupResetAfterInactivitySeconds) {
         return;
         return;
     } else if (nowSecs - session->timeOfLastPacket < session->resetAfterInactivitySeconds) {
     } else if (nowSecs - session->timeOfLastPacket < session->resetAfterInactivitySeconds) {
@@ -531,7 +531,7 @@ int CryptoAuth_encrypt(struct CryptoAuth_Session* sessionPub, struct Message* ms
 /** Call the external interface and tell it that a message has been received. */
 /** Call the external interface and tell it that a message has been received. */
 static inline void updateTime(struct CryptoAuth_Session_pvt* session, struct Message* message)
 static inline void updateTime(struct CryptoAuth_Session_pvt* session, struct Message* message)
 {
 {
-    session->timeOfLastPacket = Time_currentTimeSeconds(session->context->eventBase);
+    session->timeOfLastPacket = Time_currentTimeSeconds();
 }
 }
 
 
 static inline enum CryptoAuth_DecryptErr decryptMessage(struct CryptoAuth_Session_pvt* session,
 static inline enum CryptoAuth_DecryptErr decryptMessage(struct CryptoAuth_Session_pvt* session,
@@ -1105,7 +1105,7 @@ struct CryptoAuth_Session* CryptoAuth_newSession(struct CryptoAuth* ca,
     session->context = context;
     session->context = context;
     session->requireAuth = requireAuth;
     session->requireAuth = requireAuth;
     session->displayName = displayName ? String_new(displayName, alloc) : NULL;
     session->displayName = displayName ? String_new(displayName, alloc) : NULL;
-    session->timeOfLastPacket = Time_currentTimeSeconds(context->eventBase);
+    session->timeOfLastPacket = Time_currentTimeSeconds();
     session->alloc = alloc;
     session->alloc = alloc;
 
 
     session->resetAfterInactivitySeconds = CryptoAuth_DEFAULT_RESET_AFTER_INACTIVITY_SECONDS;
     session->resetAfterInactivitySeconds = CryptoAuth_DEFAULT_RESET_AFTER_INACTIVITY_SECONDS;

+ 4 - 4
dht/dhtcore/Janitor.c

@@ -101,7 +101,7 @@ struct Janitor_Search
 
 
 static bool isBlacklisted(struct Janitor_pvt* j, uint64_t path)
 static bool isBlacklisted(struct Janitor_pvt* j, uint64_t path)
 {
 {
-    int64_t now = Time_currentTimeMilliseconds(j->eventBase);
+    int64_t now = Time_currentTimeMilliseconds();
     for (int i = 0; i < Janitor_pvt_blacklist_NUM; i++) {
     for (int i = 0; i < Janitor_pvt_blacklist_NUM; i++) {
         struct Janitor_Blacklist* qp = &j->blacklist[i];
         struct Janitor_Blacklist* qp = &j->blacklist[i];
         if (qp->path == path && now - qp->timeAdded < j->pub.blacklistPathForMilliseconds) {
         if (qp->path == path && now - qp->timeAdded < j->pub.blacklistPathForMilliseconds) {
@@ -113,7 +113,7 @@ static bool isBlacklisted(struct Janitor_pvt* j, uint64_t path)
 
 
 static void blacklist(struct Janitor_pvt* j, uint64_t path)
 static void blacklist(struct Janitor_pvt* j, uint64_t path)
 {
 {
-    int64_t now = Time_currentTimeMilliseconds(j->eventBase);
+    int64_t now = Time_currentTimeMilliseconds();
     int oldestIndex = 0;
     int oldestIndex = 0;
     int64_t oldestTime = INT64_MAX;
     int64_t oldestTime = INT64_MAX;
     for (int i = 0; i < Janitor_pvt_blacklist_NUM; i++) {
     for (int i = 0; i < Janitor_pvt_blacklist_NUM; i++) {
@@ -598,7 +598,7 @@ static void maintanenceCycle(void* vcontext)
 {
 {
     struct Janitor_pvt* const janitor = Identity_check((struct Janitor_pvt*) vcontext);
     struct Janitor_pvt* const janitor = Identity_check((struct Janitor_pvt*) vcontext);
 
 
-    uint64_t now = Time_currentTimeMilliseconds(janitor->eventBase);
+    uint64_t now = Time_currentTimeMilliseconds();
 
 
     uint64_t nextTimeout = (janitor->pub.localMaintainenceMilliseconds / 2);
     uint64_t nextTimeout = (janitor->pub.localMaintainenceMilliseconds / 2);
     nextTimeout += Random_uint32(janitor->rand) % (nextTimeout * 2);
     nextTimeout += Random_uint32(janitor->rand) % (nextTimeout * 2);
@@ -705,7 +705,7 @@ struct Janitor* Janitor_new(struct RouterModule* routerModule,
     janitor->pub.localMaintainenceMilliseconds = Janitor_LOCAL_MAINTENANCE_MILLISECONDS_DEFAULT;
     janitor->pub.localMaintainenceMilliseconds = Janitor_LOCAL_MAINTENANCE_MILLISECONDS_DEFAULT;
     janitor->pub.blacklistPathForMilliseconds = Janitor_BLACKLIST_PATH_FOR_MILLISECONDS_DEFAULT;
     janitor->pub.blacklistPathForMilliseconds = Janitor_BLACKLIST_PATH_FOR_MILLISECONDS_DEFAULT;
 
 
-    janitor->timeOfNextGlobalMaintainence = Time_currentTimeMilliseconds(eventBase);
+    janitor->timeOfNextGlobalMaintainence = Time_currentTimeMilliseconds();
 
 
     janitor->timeout = Timeout_setTimeout(maintanenceCycle,
     janitor->timeout = Timeout_setTimeout(maintanenceCycle,
                                           janitor,
                                           janitor,

+ 6 - 6
dht/dhtcore/NodeStore.c

@@ -622,7 +622,7 @@ static struct Node_Link* linkNodes(struct Node_Two* parent,
     link->parent = parent;
     link->parent = parent;
     link->discoveredPath = discoveredPath;
     link->discoveredPath = discoveredPath;
     link->linkCost = 0;
     link->linkCost = 0;
-    link->timeLastSeen = Time_currentTimeMilliseconds(store->eventBase);
+    link->timeLastSeen = Time_currentTimeMilliseconds();
     Identity_set(link);
     Identity_set(link);
 
 
     // reverse link
     // reverse link
@@ -1358,7 +1358,7 @@ static struct Node_Link* discoverNode(struct NodeStore_pvt* store,
         child->alloc = alloc;
         child->alloc = alloc;
         Bits_memcpy(&child->address, addr, sizeof(struct Address));
         Bits_memcpy(&child->address, addr, sizeof(struct Address));
         child->encodingScheme = EncodingScheme_clone(scheme, child->alloc);
         child->encodingScheme = EncodingScheme_clone(scheme, child->alloc);
-        child->timeLastPinged = Time_currentTimeMilliseconds(store->eventBase);
+        child->timeLastPinged = Time_currentTimeMilliseconds();
         Identity_set(child);
         Identity_set(child);
     }
     }
 
 
@@ -1393,7 +1393,7 @@ static struct Node_Link* discoverNode(struct NodeStore_pvt* store,
         } while (firstHopInPath_INVALID != path);
         } while (firstHopInPath_INVALID != path);
 
 
         if (lastLink && LabelSplicer_routesThrough(addr->path, lastLink->child->address.path)) {
         if (lastLink && LabelSplicer_routesThrough(addr->path, lastLink->child->address.path)) {
-            // checking for sillyness...
+            // checking for silliness...
             Assert_true(lastLink != store->selfLink);
             Assert_true(lastLink != store->selfLink);
             NodeStore_unlinkNodes(&store->pub, lastLink);
             NodeStore_unlinkNodes(&store->pub, lastLink);
             continue;
             continue;
@@ -1639,7 +1639,7 @@ struct NodeStore* NodeStore_new(struct Address* myAddress,
     Identity_set(selfNode);
     Identity_set(selfNode);
     out->pub.selfNode = selfNode;
     out->pub.selfNode = selfNode;
     linkNodes(selfNode, selfNode, 1, 0, 0, 1, out);
     linkNodes(selfNode, selfNode, 1, 0, 0, 1, out);
-    selfNode->timeLastPinged = Time_currentTimeMilliseconds(out->eventBase);
+    selfNode->timeLastPinged = Time_currentTimeMilliseconds();
 
 
     out->pub.selfAddress = &out->selfLink->child->address;
     out->pub.selfAddress = &out->selfLink->child->address;
     out->pub.selfAddress->protocolVersion = Version_CURRENT_PROTOCOL;
     out->pub.selfAddress->protocolVersion = Version_CURRENT_PROTOCOL;
@@ -2011,7 +2011,7 @@ static void updatePathCost(struct NodeStore_pvt* store, const uint64_t path, uin
 {
 {
     struct Node_Link* link = store->selfLink;
     struct Node_Link* link = store->selfLink;
     uint64_t pathFrag = path;
     uint64_t pathFrag = path;
-    uint64_t now = Time_currentTimeMilliseconds(store->eventBase);
+    uint64_t now = Time_currentTimeMilliseconds();
     for (;;) {
     for (;;) {
         struct Node_Link* nextLink = NULL;
         struct Node_Link* nextLink = NULL;
         uint64_t nextPath = firstHopInPath(pathFrag, &nextLink, link, store);
         uint64_t nextPath = firstHopInPath(pathFrag, &nextLink, link, store);
@@ -2135,7 +2135,7 @@ uint16_t NodeStore_bucketForAddr(struct Address* source, struct Address* dest)
 uint64_t NodeStore_timeSinceLastPing(struct NodeStore* nodeStore, struct Node_Two* node)
 uint64_t NodeStore_timeSinceLastPing(struct NodeStore* nodeStore, struct Node_Two* node)
 {
 {
     struct NodeStore_pvt* store = Identity_check((struct NodeStore_pvt*)nodeStore);
     struct NodeStore_pvt* store = Identity_check((struct NodeStore_pvt*)nodeStore);
-    uint64_t now = Time_currentTimeMilliseconds(store->eventBase);
+    uint64_t now = Time_currentTimeMilliseconds();
     uint64_t lastSeen = node->timeLastPinged;
     uint64_t lastSeen = node->timeLastPinged;
     struct Node_Link* link = Node_getBestParent(node);
     struct Node_Link* link = Node_getBestParent(node);
     while (link && link != store->selfLink) {
     while (link && link != store->selfLink) {

+ 1 - 1
dht/dhtcore/RouterModule.c

@@ -466,7 +466,7 @@ static int handleIncoming(struct DHTMessage* message, void* vcontext)
 
 
     struct RouterModule* module = Identity_check((struct RouterModule*) vcontext);
     struct RouterModule* module = Identity_check((struct RouterModule*) vcontext);
 
 
-    // This is retreived below by onResponseOrTimeout()
+    // This is retrieved below by onResponseOrTimeout()
     module->currentMessage = message;
     module->currentMessage = message;
     Pinger_pongReceived(txid, module->pinger);
     Pinger_pongReceived(txid, module->pinger);
     module->currentMessage = NULL;
     module->currentMessage = NULL;

+ 4 - 4
doc/Whitepaper.md

@@ -524,7 +524,7 @@ The Switch Header may be followed by three different types of packets:
   The CryptoAuth handshake packet contains the Session Handle (that should
   The CryptoAuth handshake packet contains the Session Handle (that should
   be used by the recipient to prefix CryptoAuth data packets sent after that),
   be used by the recipient to prefix CryptoAuth data packets sent after that),
   eventually followed by a Switch Data Header.
   eventually followed by a Switch Data Header.
-* Otherwise, these first four bytes are a Session Handle, which the receipient
+* Otherwise, these first four bytes are a Session Handle, which the recipient
   of these packet chose earlier to identify the emitted. They are followed
   of these packet chose earlier to identify the emitted. They are followed
   by a CryptoAuth Data Packet, containing a Switch Data Header.
   by a CryptoAuth Data Packet, containing a Switch Data Header.
 
 
@@ -658,7 +658,7 @@ Possible keys in a router message include:
 * `p` (integer): protocol version. Matches the cjdns version.
 * `p` (integer): protocol version. Matches the cjdns version.
 * `tar` (byte string): the target address. If provided, contains an address
 * `tar` (byte string): the target address. If provided, contains an address
   the sender wants to reach.
   the sender wants to reach.
-* `txid` (byte string): transaction id. Opaque value choosen by senders of
+* `txid` (byte string): transaction id. Opaque value chosen by senders of
   queries, which must be used in responses.
   queries, which must be used in responses.
 
 
 The serialization of each item of the list of nodes `n` is:
 The serialization of each item of the list of nodes `n` is:
@@ -902,7 +902,7 @@ assuming they are not “too late” and are not replays.
 To do that, it stores a 64-bit bitfield, with a bit for each of the 64
 To do that, it stores a 64-bit bitfield, with a bit for each of the 64
 nonces before the highest nonce received so far.
 nonces before the highest nonce received so far.
 Every time a packet is received with a nonce between `highestnonce - 64`
 Every time a packet is received with a nonce between `highestnonce - 64`
-(excluded) and `highestnonce` (included), it substracts the packet's nonce
+(excluded) and `highestnonce` (included), it subtracts the packet's nonce
 to the highest nonce, giving a number n, and looks at the n-th bit
 to the highest nonce, giving a number n, and looks at the n-th bit
 of the bitfield. If it is one, the packet is a replay and is dropped.
 of the bitfield. If it is one, the packet is a replay and is dropped.
 If it is zero, the packet passes, and the bit is set to one.
 If it is zero, the packet passes, and the bit is set to one.
@@ -969,7 +969,7 @@ of the hash of the password (counting indexes from 1). This is used as a sort
 of username so that the other end knows which password to try using in the
 of username so that the other end knows which password to try using in the
 handshake.
 handshake.
 
 
-AuthType Two is prefered to this method because it may be harder to crack
+AuthType Two is preferred to this method because it may be harder to crack
 (does not leak bytes of the value computing from the password).
 (does not leak bytes of the value computing from the password).
 
 
 ##### AuthType Two
 ##### AuthType Two

+ 6 - 0
doc/nat-gateway.md

@@ -74,6 +74,12 @@ Now enter the ip6tables rules:
     ip6tables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
     ip6tables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
     ip6tables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
     ip6tables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
     ip6tables -A FORWARD -i eth1 -o eth0 -j ACCEPT
     ip6tables -A FORWARD -i eth1 -o eth0 -j ACCEPT
+    
+Or if you use nftables:
+
+    nft add rule ip6 nat POSTROUTING oifname "tun0" counter masquerade
+    nft add rule ip6 filter FORWARD iifname "tun0" oifname "eth0" ct state related,established accept
+    nft add rule ip6 filter FORWARD iifname "eth1" oifname "eth0" accept
 
 
 Save the rules:
 Save the rules:
 
 

+ 10 - 10
net/InterfaceController.c

@@ -308,7 +308,7 @@ static void onPingResponse(struct SwitchPinger_Response* resp, void* onResponseC
         sendPeer(0xffffffff, PFChan_Core_PEER, ep, resp->milliseconds);
         sendPeer(0xffffffff, PFChan_Core_PEER, ep, resp->milliseconds);
     }
     }
 
 
-    ep->timeOfLastPing = Time_currentTimeMilliseconds(ic->eventBase);
+    ep->timeOfLastPing = Time_currentTimeMilliseconds();
 
 
     if (Defined(Log_DEBUG)) {
     if (Defined(Log_DEBUG)) {
         String* addr = Address_toString(&ep->addr, resp->ping->pingAlloc);
         String* addr = Address_toString(&ep->addr, resp->ping->pingAlloc);
@@ -404,7 +404,7 @@ static void linkState(void* vic)
 static void iciPing(struct InterfaceController_Iface_pvt* ici, struct InterfaceController_pvt* ic)
 static void iciPing(struct InterfaceController_Iface_pvt* ici, struct InterfaceController_pvt* ic)
 {
 {
     if (!ici->peerMap.count) { return; }
     if (!ici->peerMap.count) { return; }
-    uint64_t now = Time_currentTimeMilliseconds(ic->eventBase);
+    uint64_t now = Time_currentTimeMilliseconds();
 
 
     // scan for endpoints have not sent anything recently.
     // scan for endpoints have not sent anything recently.
     uint32_t startAt = ici->lastPeerPinged = (ici->lastPeerPinged + 1) % ici->peerMap.count;
     uint32_t startAt = ici->lastPeerPinged = (ici->lastPeerPinged + 1) % ici->peerMap.count;
@@ -534,7 +534,7 @@ static Iface_DEFUN sendFromSwitch(struct Message* msg, struct Iface* switchIf)
 
 
     ep->bytesOut += Message_getLength(msg);
     ep->bytesOut += Message_getLength(msg);
 
 
-    Kbps_accumulate(&ep->sendBw, Time_currentTimeMilliseconds(ep->ici->ic->eventBase), Message_getLength(msg));
+    Kbps_accumulate(&ep->sendBw, Time_currentTimeMilliseconds(), Message_getLength(msg));
 
 
     return Iface_next(&ep->plaintext, msg); // --> afterEncrypt
     return Iface_next(&ep->plaintext, msg); // --> afterEncrypt
 }
 }
@@ -701,10 +701,10 @@ static Iface_DEFUN handleBeacon(
     // the pinger will only ping every (PING_INTERVAL * 8) so we set timeOfLastMessage to
     // the pinger will only ping every (PING_INTERVAL * 8) so we set timeOfLastMessage to
     // (now - pingAfterMilliseconds - 1) so it will be considered a "lazy node".
     // (now - pingAfterMilliseconds - 1) so it will be considered a "lazy node".
     ep->timeOfLastMessage =
     ep->timeOfLastMessage =
-        Time_currentTimeMilliseconds(ic->eventBase) - ic->pingAfterMilliseconds - 1;
+        Time_currentTimeMilliseconds() - ic->pingAfterMilliseconds - 1;
 
 
     Log_info(ic->logger, "Added peer [%s] from beacon",
     Log_info(ic->logger, "Added peer [%s] from beacon",
-        Address_toString(&ep->addr, Message_getAlloc(msg))->bytes);
+    Address_toString(&ep->addr, Message_getAlloc(msg))->bytes);
 
 
     // Ping them immediately, this prevents beacon tests from taking 1 second each
     // Ping them immediately, this prevents beacon tests from taking 1 second each
     sendPing(ep);
     sendPing(ep);
@@ -771,7 +771,7 @@ static Iface_DEFUN handleIncomingFromWire(struct Message* msg, struct Iface* add
             // the pinger will only ping every (PING_INTERVAL * 8) so we set timeOfLastMessage to
             // the pinger will only ping every (PING_INTERVAL * 8) so we set timeOfLastMessage to
             // (now - pingAfterMilliseconds - 1) so it will be considered a "lazy node".
             // (now - pingAfterMilliseconds - 1) so it will be considered a "lazy node".
             ep->timeOfLastMessage =
             ep->timeOfLastMessage =
-                Time_currentTimeMilliseconds(ici->ic->eventBase) - ici->ic->pingAfterMilliseconds - 1;
+                Time_currentTimeMilliseconds() - ici->ic->pingAfterMilliseconds - 1;
 
 
             Log_info(ici->ic->logger, "Added peer [%s] from incoming message",
             Log_info(ici->ic->logger, "Added peer [%s] from incoming message",
                 Address_toString(&ep->addr, Message_getAlloc(msg))->bytes);
                 Address_toString(&ep->addr, Message_getAlloc(msg))->bytes);
@@ -842,7 +842,7 @@ static Iface_DEFUN afterDecrypt(struct Message* msg, struct Iface* plaintext)
         return Error(msg, "AUTHENTICATION");
         return Error(msg, "AUTHENTICATION");
     }
     }
 
 
-    Kbps_accumulate(&ep->recvBw, Time_currentTimeMilliseconds(ic->eventBase), Message_getLength(msg));
+    Kbps_accumulate(&ep->recvBw, Time_currentTimeMilliseconds(), Message_getLength(msg));
     ep->bytesIn += Message_getLength(msg);
     ep->bytesIn += Message_getLength(msg);
 
 
     int caState = Ca_getState(ep->caSession);
     int caState = Ca_getState(ep->caSession);
@@ -872,7 +872,7 @@ static Iface_DEFUN afterDecrypt(struct Message* msg, struct Iface* plaintext)
         if (ep->state != caState) {
         if (ep->state != caState) {
             sendPeer(0xffffffff, PFChan_Core_PEER, ep, 0xffff);
             sendPeer(0xffffffff, PFChan_Core_PEER, ep, 0xffff);
         }
         }
-        ep->timeOfLastMessage = Time_currentTimeMilliseconds(ic->eventBase);
+        ep->timeOfLastMessage = Time_currentTimeMilliseconds();
     }
     }
     ep->state = caState;
     ep->state = caState;
 
 
@@ -1054,7 +1054,7 @@ int InterfaceController_bootstrapPeer(struct InterfaceController* ifc,
     // the pinger will only ping every (PING_INTERVAL * 8) so we set timeOfLastMessage to
     // the pinger will only ping every (PING_INTERVAL * 8) so we set timeOfLastMessage to
     // (now - pingAfterMilliseconds - 1) so it will be considered a "lazy node".
     // (now - pingAfterMilliseconds - 1) so it will be considered a "lazy node".
     ep->timeOfLastMessage =
     ep->timeOfLastMessage =
-        Time_currentTimeMilliseconds(ic->eventBase) - ic->pingAfterMilliseconds - 1;
+        Time_currentTimeMilliseconds() - ic->pingAfterMilliseconds - 1;
 
 
     if (Defined(Log_INFO)) {
     if (Defined(Log_INFO)) {
         struct Allocator* tempAlloc = Allocator_child(ep->alloc);
         struct Allocator* tempAlloc = Allocator_child(ep->alloc);
@@ -1087,7 +1087,7 @@ int InterfaceController_getPeerStats(struct InterfaceController* ifController,
     struct InterfaceController_PeerStats* stats =
     struct InterfaceController_PeerStats* stats =
         Allocator_calloc(alloc, sizeof(struct InterfaceController_PeerStats), count);
         Allocator_calloc(alloc, sizeof(struct InterfaceController_PeerStats), count);
 
 
-    uint32_t now = Time_currentTimeMilliseconds(ic->eventBase);
+    uint32_t now = Time_currentTimeMilliseconds();
     int xcount = 0;
     int xcount = 0;
     for (int j = 0; j < ic->icis->length; j++) {
     for (int j = 0; j < ic->icis->length; j++) {
         struct InterfaceController_Iface_pvt* ici = ArrayList_OfIfaces_get(ic->icis, j);
         struct InterfaceController_Iface_pvt* ici = ArrayList_OfIfaces_get(ic->icis, j);

+ 7 - 7
net/SessionManager.c

@@ -210,7 +210,7 @@ struct SessionManager_HandleList* SessionManager_getHandleList(struct SessionMan
 static uint32_t effectiveMetric(struct SessionManager_pvt* sm,
 static uint32_t effectiveMetric(struct SessionManager_pvt* sm,
                                 SessionManager_Path_t* path)
                                 SessionManager_Path_t* path)
 {
 {
-    int64_t x = Time_currentTimeMilliseconds(sm->eventBase) - path->timeLastValidated;
+    int64_t x = Time_currentTimeMilliseconds() - path->timeLastValidated;
     x += path->metric;
     x += path->metric;
     return (x > Metric_NO_INFO) ? Metric_NO_INFO : x;
     return (x > Metric_NO_INFO) ? Metric_NO_INFO : x;
 }
 }
@@ -275,7 +275,7 @@ static bool discoverPath(struct SessionManager_Session_pvt* sess,
         return false;
         return false;
     }
     }
     SessionManager_Path_t* path = pathForLabel(sess, label);
     SessionManager_Path_t* path = pathForLabel(sess, label);
-    uint64_t now = Time_currentTimeMilliseconds(sess->sessionManager->eventBase);
+    uint64_t now = Time_currentTimeMilliseconds();
     if (path) {
     if (path) {
         if (metric != Metric_DEAD_LINK && effectiveMetric(sess->sessionManager, path) <= metric) {
         if (metric != Metric_DEAD_LINK && effectiveMetric(sess->sessionManager, path) <= metric) {
             // already have a better source of truth
             // already have a better source of truth
@@ -453,7 +453,7 @@ static struct SessionManager_Session_pvt* getSession(struct SessionManager_pvt*
                   printedIp6, sess->pub.receiveHandle);
                   printedIp6, sess->pub.receiveHandle);
     }
     }
 
 
-    int64_t now = Time_currentTimeMilliseconds(sm->eventBase);
+    int64_t now = Time_currentTimeMilliseconds();
     sess->alloc = alloc;
     sess->alloc = alloc;
     sess->sessionManager = sm;
     sess->sessionManager = sm;
     sess->pub.version = version;
     sess->pub.version = version;
@@ -563,7 +563,7 @@ static void checkTimedOutBuffers(struct SessionManager_pvt* sm)
 {
 {
     for (int i = 0; i < (int)sm->bufMap.count; i++) {
     for (int i = 0; i < (int)sm->bufMap.count; i++) {
         struct BufferedMessage* buffered = sm->bufMap.values[i];
         struct BufferedMessage* buffered = sm->bufMap.values[i];
-        int64_t lag = Time_currentTimeMilliseconds(sm->eventBase) - buffered->timeSentMilliseconds;
+        int64_t lag = Time_currentTimeMilliseconds() - buffered->timeSentMilliseconds;
         if (lag < 10000) { continue; }
         if (lag < 10000) { continue; }
         Map_BufferedMessages_remove(i, &sm->bufMap);
         Map_BufferedMessages_remove(i, &sm->bufMap);
         Allocator_free(buffered->alloc);
         Allocator_free(buffered->alloc);
@@ -623,7 +623,7 @@ static void checkTimedOutSessions(struct SessionManager_pvt* sm)
 {
 {
     for (int i = (int)sm->ifaceMap.count - 1; i >= 0; i--) {
     for (int i = (int)sm->ifaceMap.count - 1; i >= 0; i--) {
         struct SessionManager_Session_pvt* sess = sm->ifaceMap.values[i];
         struct SessionManager_Session_pvt* sess = sm->ifaceMap.values[i];
-        int64_t now = Time_currentTimeMilliseconds(sm->eventBase);
+        int64_t now = Time_currentTimeMilliseconds();
 
 
         // Check if the session is timed out...
         // Check if the session is timed out...
         SessionManager_Path_t* path = mostRecentValidatedPath(sess);
         SessionManager_Path_t* path = mostRecentValidatedPath(sess);
@@ -699,7 +699,7 @@ static void bufferPacket(struct SessionManager_pvt* sm, struct Message* msg)
         Allocator_calloc(lookupAlloc, sizeof(struct BufferedMessage), 1);
         Allocator_calloc(lookupAlloc, sizeof(struct BufferedMessage), 1);
     buffered->msg = msg;
     buffered->msg = msg;
     buffered->alloc = lookupAlloc;
     buffered->alloc = lookupAlloc;
-    buffered->timeSentMilliseconds = Time_currentTimeMilliseconds(sm->eventBase);
+    buffered->timeSentMilliseconds = Time_currentTimeMilliseconds();
     Allocator_adopt(lookupAlloc, Message_getAlloc(msg));
     Allocator_adopt(lookupAlloc, Message_getAlloc(msg));
     Assert_true(Map_BufferedMessages_put((struct Ip6*)header->ip6, &buffered, &sm->bufMap) > -1);
     Assert_true(Map_BufferedMessages_put((struct Ip6*)header->ip6, &buffered, &sm->bufMap) > -1);
 }
 }
@@ -783,7 +783,7 @@ static Iface_DEFUN incomingFromInsideIf(struct Message* msg, struct Iface* iface
 
 
     if (!(header->flags & RouteHeader_flags_PATHFINDER)) {
     if (!(header->flags & RouteHeader_flags_PATHFINDER)) {
         // It's real life user traffic, lets tag the time of last use
         // It's real life user traffic, lets tag the time of last use
-        sess->pub.timeOfLastUsage = Time_currentTimeMilliseconds(sm->eventBase);
+        sess->pub.timeOfLastUsage = Time_currentTimeMilliseconds();
     }
     }
 
 
     if (header->version_be) { sess->pub.version = Endian_bigEndianToHost32(header->version_be); }
     if (header->version_be) { sess->pub.version = Endian_bigEndianToHost32(header->version_be); }

+ 1 - 1
node_build/CjdnsTest.js

@@ -144,7 +144,7 @@ module.exports.generate = function (builder, isSubnode, callback) {
             //console.log(test);
             //console.log(test);
             const testProto = /^.*\/([^\/]+)\.c$/.exec(test)[1];
             const testProto = /^.*\/([^\/]+)\.c$/.exec(test)[1];
             builder.config.cjdnsTest_files.push(test);
             builder.config.cjdnsTest_files.push(test);
-            const cflags = (builder.config.fileCflags[test] = builder.config.fileCflags[test] || []);
+            const cflags = (builder.fileCflags[test] = builder.fileCflags[test] || []);
             if (test.indexOf('_fuzz_test') > -1) {
             if (test.indexOf('_fuzz_test') > -1) {
                 cflags.push(
                 cflags.push(
                     '-D', 'CJDNS_FUZZ_INIT='+testProto+'_FUZZ_INIT',
                     '-D', 'CJDNS_FUZZ_INIT='+testProto+'_FUZZ_INIT',

+ 14 - 5
node_build/builder.js

@@ -54,7 +54,8 @@ export type Builder_t = {|
     lintFiles: (Builder_Linter_t)=>void,
     lintFiles: (Builder_Linter_t)=>void,
     config: Builder_Config_t,
     config: Builder_Config_t,
     tmpFile: (?string)=>string,
     tmpFile: (?string)=>string,
-    compilerType: () => Builder_Compiler_t
+    compilerType: () => Builder_Compiler_t,
+    fileCflags: {[string]: string[]},
 |};
 |};
 export type Builder_BaseConfig_t = {|
 export type Builder_BaseConfig_t = {|
     systemName?: ?string,
     systemName?: ?string,
@@ -70,7 +71,6 @@ export type Builder_Config_t = {
     ldflags: string[],
     ldflags: string[],
     libs: string[],
     libs: string[],
     jobs: number,
     jobs: number,
-    fileCflags: {[string]: string[]},
 } & {[string]:any};
 } & {[string]:any};
 import type { Nthen_WaitFor_t } from 'nthen';
 import type { Nthen_WaitFor_t } from 'nthen';
 import type { Saferphore_t } from 'saferphore';
 import type { Saferphore_t } from 'saferphore';
@@ -80,6 +80,14 @@ export type Builder_CompileJob_t = {
     outputFile: ?string,
     outputFile: ?string,
     type: 'exe'|'lib'
     type: 'exe'|'lib'
 };
 };
+export type Builder_Pub_t = {|
+    build: (Builder_Stage_t)=>Builder_Pub_t,
+    test: (Builder_Stage_t)=>Builder_Pub_t,
+    pack: (Builder_Stage_t)=>Builder_Pub_t,
+    failure: (Builder_Stage_t)=>Builder_Pub_t,
+    success: (Builder_Stage_t)=>Builder_Pub_t,
+    complete: (Builder_Stage_t)=>Builder_Pub_t,
+|}
 export type Builder_PreCtx_t = {
 export type Builder_PreCtx_t = {
     buildStage: Builder_Stage_t,
     buildStage: Builder_Stage_t,
     testStage: Builder_Stage_t,
     testStage: Builder_Stage_t,
@@ -256,6 +264,8 @@ const finalizeCtx = function (
 
 
         compilerType: () => JSON.parse(JSON.stringify(ctx.state.compilerType)),
         compilerType: () => JSON.parse(JSON.stringify(ctx.state.compilerType)),
 
 
+        fileCflags: {},
+
     }) /*:Builder_t*/);
     }) /*:Builder_t*/);
     return ctx;
     return ctx;
 };
 };
@@ -431,7 +441,7 @@ const getExeFile = function (ctx, exe /*:Builder_CompileJob_t*/) {
 const getFlags = function (ctx, cFile, includeDirs) {
 const getFlags = function (ctx, cFile, includeDirs) {
     const flags = [];
     const flags = [];
     flags.push.apply(flags, ctx.config.cflags);
     flags.push.apply(flags, ctx.config.cflags);
-    flags.push.apply(flags, ctx.builder.config.fileCflags[cFile] || []);
+    flags.push.apply(flags, ctx.builder.fileCflags[cFile] || []);
     if (includeDirs) {
     if (includeDirs) {
         for (let i = 0; i < ctx.config.includeDirs.length; i++) {
         for (let i = 0; i < ctx.config.includeDirs.length; i++) {
             if (flags[flags.indexOf(ctx.config.includeDirs[i])-1] === '-I') {
             if (flags[flags.indexOf(ctx.config.includeDirs[i])-1] === '-I') {
@@ -766,7 +776,7 @@ const sweep = (path, done) => {
 module.exports.configure = function (
 module.exports.configure = function (
     params /*:Builder_BaseConfig_t*/,
     params /*:Builder_BaseConfig_t*/,
     configFunc /*:(Builder_t, Nthen_WaitFor_t)=>void*/
     configFunc /*:(Builder_t, Nthen_WaitFor_t)=>void*/
-) {
+) /*:Builder_Pub_t*/ {
 
 
     // Track time taken for various steps
     // Track time taken for various steps
     const time = makeTime();
     const time = makeTime();
@@ -819,7 +829,6 @@ module.exports.configure = function (
             cflags: [],
             cflags: [],
             ldflags: [],
             ldflags: [],
             libs: [],
             libs: [],
-            fileCflags: {},
             jobs,
             jobs,
         },
         },
     };
     };

+ 1 - 1
node_build/run_jshint

@@ -20,7 +20,7 @@ main()
     JSHINT="`pwd`/node_modules/jshint/bin/jshint"
     JSHINT="`pwd`/node_modules/jshint/bin/jshint"
 
 
     echo "Running JSHint..."
     echo "Running JSHint..."
-    ${JSHINT} --config node_build/.jshintrc \
+    ${JSHINT} --config .jshintrc \
               --exclude-path .jshintignore \
               --exclude-path .jshintignore \
               --reporter node_build/JSHintReporter.js . || return 1
               --reporter node_build/JSHintReporter.js . || return 1
 
 

+ 24 - 0
rust/cjdns_sys/Rffi.h

@@ -74,4 +74,28 @@ RTypes_Error_t *Rffi_error_fl(const char *msg, const char *file, int line, Alloc
 
 
 const char *Rffi_printError(RTypes_Error_t *e, Allocator_t *alloc);
 const char *Rffi_printError(RTypes_Error_t *e, Allocator_t *alloc);
 
 
+/**
+ * Replaces libuv's function:
+ *
+ * int uv_inet_ntop(int af, const void* src, char* dst, size_t size)
+ */
+int32_t Rffi_inet_ntop(bool is_ip6, const void *addr, uint8_t *dst, uint32_t dst_sz);
+
+/**
+ * Replaces libuv's function:
+ *
+ * int uv_inet_pton(int af, const char* src, void* dst) {
+ */
+int32_t Rffi_inet_pton(bool is_ip6, const char *src, uint8_t *addr);
+
+/**
+ * Non-monotonic nanosecond time, which has no relationship to any wall clock.
+ */
+uint64_t Rffi_hrtime(void);
+
+/**
+ * Monotonic millisecond time.
+ */
+uint64_t Rffi_now_ms(void);
+
 #endif /* rffi_H */
 #endif /* rffi_H */

+ 0 - 0
rust/cjdroute/src/main.rs → rust/cjdns_sys/src/bin/cjdroute.rs


+ 0 - 0
rust/makekeys/src/main.rs → rust/cjdns_sys/src/bin/makekeys.rs


+ 0 - 0
rust/mkpasswd/src/main.rs → rust/cjdns_sys/src/bin/mkpasswd.rs


+ 0 - 0
rust/privatetopublic/src/main.rs → rust/cjdns_sys/src/bin/privatetopublic.rs


+ 0 - 0
rust/publictoip6/src/main.rs → rust/cjdns_sys/src/bin/publictoip6.rs


+ 0 - 0
rust/randombytes/src/main.rs → rust/cjdns_sys/src/bin/randombytes.rs


+ 0 - 0
rust/sybilsim/src/main.rs → rust/cjdns_sys/src/bin/sybilsim.rs


+ 0 - 0
rust/testcjdroute/src/main.rs → rust/cjdns_sys/src/bin/testcjdroute.rs


+ 1 - 0
rust/cjdns_sys/src/interface/wire/message.rs

@@ -1,6 +1,7 @@
 //! Message type.
 //! Message type.
 
 
 use std::slice::{from_raw_parts, from_raw_parts_mut};
 use std::slice::{from_raw_parts, from_raw_parts_mut};
+use std::i32;
 
 
 use thiserror::Error;
 use thiserror::Error;
 
 

+ 80 - 4
rust/cjdns_sys/src/rffi.rs

@@ -1,9 +1,6 @@
 #![allow(non_snake_case)]
 #![allow(non_snake_case)]
 #![allow(non_camel_case_types)]
 #![allow(non_camel_case_types)]
 
 
-use std::os::raw::{c_char, c_int};
-use std::sync::Arc;
-
 use crate::bytestring::ByteString;
 use crate::bytestring::ByteString;
 use crate::cffi::{self, Allocator_t, Random_t, String_t};
 use crate::cffi::{self, Allocator_t, Random_t, String_t};
 use crate::crypto::crypto_auth;
 use crate::crypto::crypto_auth;
@@ -14,6 +11,11 @@ use crate::external::interface::cif;
 use crate::external::memory::allocator;
 use crate::external::memory::allocator;
 use crate::rtypes::*;
 use crate::rtypes::*;
 use crate::interface::wire::message::Message;
 use crate::interface::wire::message::Message;
+use std::ffi::{c_void, CStr};
+use std::os::raw::{c_char, c_int};
+use std::sync::Once;
+use std::sync::Arc;
+use std::time::{Duration, Instant, SystemTime};
 
 
 // This file is used to generate cbindings.h using cbindgen
 // This file is used to generate cbindings.h using cbindgen
 
 
@@ -382,4 +384,78 @@ pub unsafe extern "C" fn Rffi_printError(
         .flatten()
         .flatten()
         .map(|e|str_to_c(&format!("{:?}", e), alloc))
         .map(|e|str_to_c(&format!("{:?}", e), alloc))
         .unwrap_or_else(std::ptr::null)
         .unwrap_or_else(std::ptr::null)
-}
+}
+
+/// Replaces libuv's function:
+///
+/// int uv_inet_ntop(int af, const void* src, char* dst, size_t size)
+#[no_mangle]
+pub unsafe extern "C" fn Rffi_inet_ntop(
+    is_ip6: bool,
+    addr: *const c_void,
+    dst: *mut u8,
+    dst_sz: u32,
+) -> i32 {
+    let ip_repr = if is_ip6 {
+        let addr = addr as *const [u8; 16];
+        std::net::Ipv6Addr::from(*addr).to_string()
+    } else {
+        let addr = addr as *const [u8; 4];
+        std::net::Ipv4Addr::from(*addr).to_string()
+    };
+    if ip_repr.len() >= dst_sz as usize {
+        return -1;
+    }
+    let dst = std::slice::from_raw_parts_mut(dst, dst_sz as usize);
+    dst[..ip_repr.len()].copy_from_slice(ip_repr.as_bytes());
+    dst[ip_repr.len()] = b'\0';
+    0
+}
+
+/// Replaces libuv's function:
+///
+/// int uv_inet_pton(int af, const char* src, void* dst) {
+#[no_mangle]
+pub unsafe extern "C" fn Rffi_inet_pton(is_ip6: bool, src: *const c_char, addr: *mut u8) -> i32 {
+    let src = CStr::from_ptr(src).to_string_lossy();
+    let octets = if is_ip6 {
+        match src.parse::<std::net::Ipv6Addr>() {
+            Ok(addr) => addr.octets().to_vec(),
+            Err(_) => return -1,
+        }
+    } else {
+        match src.parse::<std::net::Ipv4Addr>() {
+            Ok(addr) => addr.octets().to_vec(),
+            Err(_) => return -1,
+        }
+    };
+    let addr = std::slice::from_raw_parts_mut(addr, octets.len());
+    addr.copy_from_slice(&octets);
+    0
+}
+
+/// Non-monotonic nanosecond time, which has no relationship to any wall clock.
+#[no_mangle]
+pub unsafe extern "C" fn Rffi_hrtime() -> u64 {
+    now_unix_epoch().as_nanos() as u64
+}
+
+fn now_unix_epoch() -> Duration {
+    SystemTime::now()
+        .duration_since(SystemTime::UNIX_EPOCH)
+        .unwrap()
+}
+
+static mut BASE_INSTANT: Option<Instant> = None;
+static mut INSTANT_OFFSET: u64 = 0;
+static INIT: Once = Once::new();
+
+/// Monotonic millisecond time.
+#[no_mangle]
+pub unsafe extern "C" fn Rffi_now_ms() -> u64 {
+    INIT.call_once(|| {
+        BASE_INSTANT = Some(Instant::now());
+        INSTANT_OFFSET = now_unix_epoch().as_millis() as u64;
+    });
+    (Instant::now() - BASE_INSTANT.unwrap()).as_millis() as u64 + INSTANT_OFFSET
+}

+ 0 - 10
rust/cjdroute/Cargo.toml

@@ -1,10 +0,0 @@
-[package]
-name = "cjdroute"
-version = "0.1.0"
-authors = ["Caleb James DeLisle <cjd@cjdns.fr>"]
-edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-cjdns_sys = { path = "../cjdns_sys" }

+ 0 - 10
rust/makekeys/Cargo.toml

@@ -1,10 +0,0 @@
-[package]
-name = "makekeys"
-version = "0.1.0"
-authors = ["Caleb James DeLisle <cjd@cjdns.fr>"]
-edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-cjdns_sys = { path = "../cjdns_sys" }

+ 0 - 10
rust/mkpasswd/Cargo.toml

@@ -1,10 +0,0 @@
-[package]
-name = "mkpasswd"
-version = "0.1.0"
-authors = ["Caleb James DeLisle <cjd@cjdns.fr>"]
-edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-cjdns_sys = { path = "../cjdns_sys" }

+ 0 - 10
rust/privatetopublic/Cargo.toml

@@ -1,10 +0,0 @@
-[package]
-name = "privatetopublic"
-version = "0.1.0"
-authors = ["Caleb James DeLisle <cjd@cjdns.fr>"]
-edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-cjdns_sys = { path = "../cjdns_sys" }

+ 0 - 10
rust/publictoip6/Cargo.toml

@@ -1,10 +0,0 @@
-[package]
-name = "publictoip6"
-version = "0.1.0"
-authors = ["Caleb James DeLisle <cjd@cjdns.fr>"]
-edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-cjdns_sys = { path = "../cjdns_sys" }

+ 0 - 10
rust/randombytes/Cargo.toml

@@ -1,10 +0,0 @@
-[package]
-name = "randombytes"
-version = "0.1.0"
-authors = ["Caleb James DeLisle <cjd@cjdns.fr>"]
-edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-cjdns_sys = { path = "../cjdns_sys" }

+ 0 - 10
rust/sybilsim/Cargo.toml

@@ -1,10 +0,0 @@
-[package]
-name = "sybilsim"
-version = "0.1.0"
-authors = ["Caleb James DeLisle <cjd@cjdns.fr>"]
-edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-cjdns_sys = { path = "../cjdns_sys" }

+ 0 - 10
rust/testcjdroute/Cargo.toml

@@ -1,10 +0,0 @@
-[package]
-name = "testcjdroute"
-version = "0.1.0"
-authors = ["Caleb James DeLisle <cjd@cjdns.fr>"]
-edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-cjdns_sys = { path = "../cjdns_sys" }

+ 1 - 1
subnode/ReachabilityAnnouncer.c

@@ -240,7 +240,7 @@ struct ReachabilityAnnouncer_pvt
 
 
 static int64_t ourTime(struct ReachabilityAnnouncer_pvt* rap)
 static int64_t ourTime(struct ReachabilityAnnouncer_pvt* rap)
 {
 {
-    uint64_t now = Time_currentTimeMilliseconds(rap->base);
+    uint64_t now = Time_currentTimeMilliseconds();
     Assert_true(!(now >> 63));
     Assert_true(!(now >> 63));
     return (int64_t) now;
     return (int64_t) now;
 }
 }

+ 1 - 1
subnode/ReachabilityCollector.c

@@ -203,7 +203,7 @@ static void latencyUpdate(
     //Log_debug(rcp->log, "Latency update for [%" PRIx64 "] [%u]ms", pip->pub.addr.path, lag);
     //Log_debug(rcp->log, "Latency update for [%" PRIx64 "] [%u]ms", pip->pub.addr.path, lag);
     pip->sumOfLag += lag;
     pip->sumOfLag += lag;
     pip->lagSamples++;
     pip->lagSamples++;
-    pip->timeOfLastLagUpdate = Time_currentTimeMilliseconds(rcp->base);
+    pip->timeOfLastLagUpdate = Time_currentTimeMilliseconds();
 }
 }
 
 
 static void onReplyOld(Dict* msg, struct Address* src, struct MsgCore_Promise* prom)
 static void onReplyOld(Dict* msg, struct Address* src, struct MsgCore_Promise* prom)

+ 4 - 4
subnode/SupernodeHunter.c

@@ -174,7 +174,7 @@ static void adoptSupernode(struct SupernodeHunter_pvt* snp, struct Address* cand
     struct Query* q = Allocator_calloc(qp->alloc, sizeof(struct Query), 1);
     struct Query* q = Allocator_calloc(qp->alloc, sizeof(struct Query), 1);
     Identity_set(q);
     Identity_set(q);
     q->snp = snp;
     q->snp = snp;
-    q->sendTime = Time_currentTimeMilliseconds(snp->base);
+    q->sendTime = Time_currentTimeMilliseconds();
 
 
     Dict* msg = qp->msg = Dict_new(qp->alloc);
     Dict* msg = qp->msg = Dict_new(qp->alloc);
     qp->cb = adoptSupernode2;
     qp->cb = adoptSupernode2;
@@ -238,7 +238,7 @@ static void updateSnodePath(struct SupernodeHunter_pvt* snp)
     struct Query* q = Allocator_calloc(qp->alloc, sizeof(struct Query), 1);
     struct Query* q = Allocator_calloc(qp->alloc, sizeof(struct Query), 1);
     Identity_set(q);
     Identity_set(q);
     q->snp = snp;
     q->snp = snp;
-    q->sendTime = Time_currentTimeMilliseconds(snp->base);
+    q->sendTime = Time_currentTimeMilliseconds();
 
 
     Dict* msg = qp->msg = Dict_new(qp->alloc);
     Dict* msg = qp->msg = Dict_new(qp->alloc);
     qp->cb = updateSnodePath2;
     qp->cb = updateSnodePath2;
@@ -260,7 +260,7 @@ static void queryForAuthorized(struct SupernodeHunter_pvt* snp, struct Address*
     struct Query* q = Allocator_calloc(qp->alloc, sizeof(struct Query), 1);
     struct Query* q = Allocator_calloc(qp->alloc, sizeof(struct Query), 1);
     Identity_set(q);
     Identity_set(q);
     q->snp = snp;
     q->snp = snp;
-    q->sendTime = Time_currentTimeMilliseconds(snp->base);
+    q->sendTime = Time_currentTimeMilliseconds();
 
 
     Dict* msg = qp->msg = Dict_new(qp->alloc);
     Dict* msg = qp->msg = Dict_new(qp->alloc);
     qp->cb = onReply;
     qp->cb = onReply;
@@ -454,7 +454,7 @@ struct SupernodeHunter* SupernodeHunter_new(struct Allocator* allocator,
     out->base = base;
     out->base = base;
     //out->rand = rand;
     //out->rand = rand;
     //out->nodes = AddrSet_new(alloc);
     //out->nodes = AddrSet_new(alloc);
-    //out->timeSnodeCalled = Time_currentTimeMilliseconds(base);
+    //out->timeSnodeCalled = Time_currentTimeMilliseconds();
     //out->snodeCandidates = AddrSet_new(alloc);
     //out->snodeCandidates = AddrSet_new(alloc);
     out->log = log;
     out->log = log;
     out->alloc = alloc;
     out->alloc = alloc;

+ 2 - 2
test/BeaconFramework.c

@@ -87,7 +87,7 @@ static Iface_DEFUN incomingTunA(struct Message* msg, struct Iface* tunA)
 
 
 static void notLinkedYet(struct TwoNodes* ctx)
 static void notLinkedYet(struct TwoNodes* ctx)
 {
 {
-    uint64_t now = Time_currentTimeMilliseconds(ctx->base);
+    uint64_t now = Time_currentTimeMilliseconds();
     if ((now - ctx->startTime) > 5000) {
     if ((now - ctx->startTime) > 5000) {
         Assert_failure("Failed to link in 5 seconds");
         Assert_failure("Failed to link in 5 seconds");
     }
     }
@@ -172,7 +172,7 @@ static void start(struct Allocator* alloc,
     out->logger = logger;
     out->logger = logger;
     out->checkLinkageTimeout = Timeout_setInterval(checkLinkage, out, 1, base, alloc);
     out->checkLinkageTimeout = Timeout_setInterval(checkLinkage, out, 1, base, alloc);
     out->base = base;
     out->base = base;
-    out->startTime = Time_currentTimeMilliseconds(base);
+    out->startTime = Time_currentTimeMilliseconds();
     out->runTest = runTest;
     out->runTest = runTest;
     out->alloc = alloc;
     out->alloc = alloc;
 
 

+ 2 - 2
test/Main_fuzz_test.c

@@ -59,7 +59,7 @@ static Iface_DEFUN incomingTun(struct Message* msg, struct Iface* tunB)
 
 
 static void notLinkedYet(struct Context* ctx)
 static void notLinkedYet(struct Context* ctx)
 {
 {
-    uint64_t now = Time_currentTimeMilliseconds(ctx->base);
+    uint64_t now = Time_currentTimeMilliseconds();
     if ((now - ctx->startTime) > 5000) {
     if ((now - ctx->startTime) > 5000) {
         Assert_failure("Failed to link in 5 seconds");
         Assert_failure("Failed to link in 5 seconds");
     }
     }
@@ -128,7 +128,7 @@ void* CJDNS_FUZZ_INIT(struct Allocator* allocator, struct Random* rand)
     ctx->logger = logger;
     ctx->logger = logger;
     ctx->checkLinkageTimeout = Timeout_setInterval(checkLinkage, ctx, 1, base, alloc);
     ctx->checkLinkageTimeout = Timeout_setInterval(checkLinkage, ctx, 1, base, alloc);
     ctx->base = base;
     ctx->base = base;
-    ctx->startTime = Time_currentTimeMilliseconds(base);
+    ctx->startTime = Time_currentTimeMilliseconds();
     ctx->alloc = alloc;
     ctx->alloc = alloc;
 
 
     Log_debug(a->logger, "Waiting for nodes to link asynchronously...");
     Log_debug(a->logger, "Waiting for nodes to link asynchronously...");

+ 1 - 1
util/ArrayList.h

@@ -22,7 +22,7 @@ Linker_require("util/ArrayList.c")
 
 
 /*
 /*
  * This struct is never defined anywhere.
  * This struct is never defined anywhere.
- * It's used in place to void* so that casts must be explicit to reduce likelyhood of error.
+ * It's used in place to void* so that casts must be explicit to reduce likelihood of error.
  */
  */
 struct ArrayList;
 struct ArrayList;
 
 

+ 2 - 2
util/AverageRoller.c

@@ -30,7 +30,7 @@ struct AverageRoller* AverageRoller_new(const uint32_t windowSeconds,
     Bits_memcpy(roller, (&(struct AverageRoller_pvt) {
     Bits_memcpy(roller, (&(struct AverageRoller_pvt) {
         .windowSeconds = windowSeconds,
         .windowSeconds = windowSeconds,
         .eventBase = eventBase,
         .eventBase = eventBase,
-        .lastUpdateTime = (uint32_t) Time_currentTimeSeconds(eventBase)
+        .lastUpdateTime = (uint32_t) Time_currentTimeSeconds()
     }), sizeof(struct AverageRoller_pvt));
     }), sizeof(struct AverageRoller_pvt));
 
 
     Identity_set(roller);
     Identity_set(roller);
@@ -83,6 +83,6 @@ uint32_t AverageRoller_update(struct AverageRoller* averageRoller, const uint32_
 {
 {
     struct AverageRoller_pvt* roller = Identity_check((struct AverageRoller_pvt*) averageRoller);
     struct AverageRoller_pvt* roller = Identity_check((struct AverageRoller_pvt*) averageRoller);
     return AverageRoller_updateAtTime(averageRoller,
     return AverageRoller_updateAtTime(averageRoller,
-                                      Time_currentTimeSeconds(roller->eventBase),
+                                      Time_currentTimeSeconds(),
                                       newEntry);
                                       newEntry);
 }
 }

+ 3 - 3
util/Pinger.c

@@ -52,7 +52,7 @@ struct Pinger
 
 
 static void callback(String* data, struct Ping* ping)
 static void callback(String* data, struct Ping* ping)
 {
 {
-    uint32_t now = Time_currentTimeMilliseconds(ping->pinger->eventBase);
+    uint32_t now = Time_currentTimeMilliseconds();
     ping->onResponse(data, now - ping->timeSent, ping->pub.context);
     ping->onResponse(data, now - ping->timeSent, ping->pub.context);
 
 
     // Flag the freePing function to tell it that the ping was not terminated by the user...
     // Flag the freePing function to tell it that the ping was not terminated by the user...
@@ -68,7 +68,7 @@ static void timeoutCallback(void* vping)
         // The ping came in at the same time that the timeout was scheduled to happen.
         // The ping came in at the same time that the timeout was scheduled to happen.
         return;
         return;
     }
     }
-    int64_t now = Time_currentTimeMilliseconds(p->pinger->eventBase);
+    int64_t now = Time_currentTimeMilliseconds();
     long long diff = ((long long) now) - ((long long)p->timeSent);
     long long diff = ((long long) now) - ((long long)p->timeSent);
     Assert_true(diff < 1000000000);
     Assert_true(diff < 1000000000);
     Log_debug(p->pinger->logger, "Ping timeout for [%u] in [%lld] ms", p->pub.handle, diff);
     Log_debug(p->pinger->logger, "Ping timeout for [%u] in [%lld] ms", p->pub.handle, diff);
@@ -112,7 +112,7 @@ struct Pinger_Ping* Pinger_newPing(String* data,
         },
         },
         .sendPing = sendPing,
         .sendPing = sendPing,
         .pinger = pinger,
         .pinger = pinger,
-        .timeSent = Time_currentTimeMilliseconds(pinger->eventBase),
+        .timeSent = Time_currentTimeMilliseconds(),
         .onResponse = onResponse
         .onResponse = onResponse
     }));
     }));
     Identity_set(ping);
     Identity_set(ping);

+ 1 - 1
util/Set.h

@@ -24,7 +24,7 @@ Linker_require("util/Set.c")
 
 
 /*
 /*
  * This struct is never defined anywhere.
  * This struct is never defined anywhere.
- * It's used in place to void* so that casts must be explicit to reduce likelyhood of error.
+ * It's used in place to void* so that casts must be explicit to reduce likelihood of error.
  */
  */
 struct Set;
 struct Set;
 struct Set_Iter;
 struct Set_Iter;

+ 2 - 3
util/events/Time.h

@@ -25,10 +25,9 @@ Linker_require("util/events/libuv/Time.c")
 uint64_t Time_hrtime(void);
 uint64_t Time_hrtime(void);
 
 
 // Monotonic time based on wall clock at time of node startup.
 // Monotonic time based on wall clock at time of node startup.
-// CAUTION: only updated once per tick, not for profiling.
-uint64_t Time_currentTimeMilliseconds(struct EventBase* eventBase);
+uint64_t Time_currentTimeMilliseconds(void);
 
 
 // Same as currentTimeMilliseconds.
 // Same as currentTimeMilliseconds.
-uint64_t Time_currentTimeSeconds(struct EventBase* eventBase);
+uint64_t Time_currentTimeSeconds(void);
 
 
 #endif
 #endif

+ 6 - 7
util/events/libuv/Time.c

@@ -12,22 +12,21 @@
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
  */
-#include "util/events/libuv/UvWrapper.h"
+#include "rust/cjdns_sys/Rffi.h"
 #include "util/events/Time.h"
 #include "util/events/Time.h"
 #include "util/events/libuv/EventBase_pvt.h"
 #include "util/events/libuv/EventBase_pvt.h"
 
 
 uint64_t Time_hrtime(void)
 uint64_t Time_hrtime(void)
 {
 {
-    return uv_hrtime();
+    return Rffi_hrtime();
 }
 }
 
 
-uint64_t Time_currentTimeMilliseconds(struct EventBase* eventBase)
+uint64_t Time_currentTimeMilliseconds()
 {
 {
-    struct EventBase_pvt* base = EventBase_privatize(eventBase);
-    return uv_now(base->loop) + base->baseTime;
+    return Rffi_now_ms();
 }
 }
 
 
-uint64_t Time_currentTimeSeconds(struct EventBase* eventBase)
+uint64_t Time_currentTimeSeconds()
 {
 {
-    return Time_currentTimeMilliseconds(eventBase) / 1024;
+    return Time_currentTimeMilliseconds() / 1024;
 }
 }

+ 19 - 1
util/events/libuv/libuv.js

@@ -11,8 +11,17 @@ module.exports = (builder, js) => {
         'src/uv-common.h',
         'src/uv-common.h',
         'src/version.c'
         'src/version.c'
     ];
     ];
+    var cflags = ['-DHAVE_CONFIG_H'];
+
+    // Normally this is built using -std=gnu89 but we're building everything
+    // with -std=c99 so adding _GNU_SOURCE fixes this issue.
+    cflags.push('-D_GNU_SOURCE');
 
 
     if (builder.config.systemName === 'win32') {
     if (builder.config.systemName === 'win32') {
+        cflags.push(
+            '-D_WIN32_WINNT=0x0600',
+            '-D_GNU_SOURCE',
+        )
         files.push(
         files.push(
             'include/uv-win.h',
             'include/uv-win.h',
             'src/win/async.c',
             'src/win/async.c',
@@ -50,6 +59,10 @@ module.exports = (builder, js) => {
             'src/win/winsock.h',
             'src/win/winsock.h',
         );
         );
     } else {
     } else {
+        cflags.push(
+            '-D_LARGEFILE_SOURCE',
+            '-D_FILE_OFFSET_BITS=64',
+        );
         files.push(
         files.push(
             'include/uv-unix.h',
             'include/uv-unix.h',
             'include/uv-linux.h',
             'include/uv-linux.h',
@@ -84,6 +97,7 @@ module.exports = (builder, js) => {
         files.push('src/unix/proctitle.c');
         files.push('src/unix/proctitle.c');
     }
     }
     if (builder.config.systemName === 'darwin') {
     if (builder.config.systemName === 'darwin') {
+        cflags.push('-D_DARWIN_USE_64_BIT_INODE=1');
         files.push(
         files.push(
             'src/unix/darwin.c',
             'src/unix/darwin.c',
             'src/unix/fsevents.c',
             'src/unix/fsevents.c',
@@ -91,6 +105,7 @@ module.exports = (builder, js) => {
         );
         );
     }
     }
     if (builder.config.systemName === 'linux') {
     if (builder.config.systemName === 'linux') {
+        cflags.push('-D_POSIX_C_SOURCE=200112');
         files.push(
         files.push(
             'src/unix/linux-core.c',
             'src/unix/linux-core.c',
             'src/unix/linux-inotify.c',
             'src/unix/linux-inotify.c',
@@ -115,7 +130,10 @@ module.exports = (builder, js) => {
     for (f of files) {
     for (f of files) {
         if (f.endsWith(".c")) {
         if (f.endsWith(".c")) {
             console.log("DEPENDENCY " + f);
             console.log("DEPENDENCY " + f);
-            js.linkerDependency("node_build/dependencies/libuv/" + f);
+            const file = "node_build/dependencies/libuv/" + f;
+            js.linkerDependency(file);
+            builder.fileCflags[file] = builder.fileCflags[file] || [];
+            builder.fileCflags[file].push(...cflags);
         }
         }
     }
     }
 }
 }

+ 6 - 5
util/platform/Sockaddr.c

@@ -12,7 +12,7 @@
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
  */
-#include "util/events/libuv/UvWrapper.h"
+#include "rust/cjdns_sys/Rffi.h"
 #include "benc/String.h"
 #include "benc/String.h"
 #include "memory/Allocator.h"
 #include "memory/Allocator.h"
 #include "util/platform/Sockaddr.h"
 #include "util/platform/Sockaddr.h"
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stddef.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdint.h>
+#include <netinet/in.h>
 
 
 struct Sockaddr_pvt
 struct Sockaddr_pvt
 {
 {
@@ -138,7 +139,7 @@ int Sockaddr_parse(const char* input, struct Sockaddr_storage* out)
     if (lastColon != firstColon) {
     if (lastColon != firstColon) {
         // ipv6
         // ipv6
         struct sockaddr_in6* in6 = (struct sockaddr_in6*) Sockaddr_asNative(&out->addr);
         struct sockaddr_in6* in6 = (struct sockaddr_in6*) Sockaddr_asNative(&out->addr);
-        if (uv_inet_pton(AF_INET6, (char*) ((buff[0] == '[') ? &buff[1] : buff), &in6->sin6_addr)) {
+        if (Rffi_inet_pton(1, (char*) ((buff[0] == '[') ? &buff[1] : buff), &in6->sin6_addr)) {
             return -1;
             return -1;
         }
         }
         out->addr.addrLen = sizeof(struct sockaddr_in6) + Sockaddr_OVERHEAD;
         out->addr.addrLen = sizeof(struct sockaddr_in6) + Sockaddr_OVERHEAD;
@@ -146,7 +147,7 @@ int Sockaddr_parse(const char* input, struct Sockaddr_storage* out)
         in6->sin6_family = AF_INET6;
         in6->sin6_family = AF_INET6;
     } else {
     } else {
         struct sockaddr_in* in = ((struct sockaddr_in*) Sockaddr_asNative(&out->addr));
         struct sockaddr_in* in = ((struct sockaddr_in*) Sockaddr_asNative(&out->addr));
-        if (uv_inet_pton(AF_INET, (char*) buff, &in->sin_addr)) {
+        if (Rffi_inet_pton(0, (char*) buff, &in->sin_addr)) {
             return -1;
             return -1;
         }
         }
         out->addr.addrLen = sizeof(struct sockaddr_in) + Sockaddr_OVERHEAD;
         out->addr.addrLen = sizeof(struct sockaddr_in) + Sockaddr_OVERHEAD;
@@ -200,7 +201,7 @@ char* Sockaddr_print(struct Sockaddr* sockaddr, struct Allocator* alloc)
 
 
     #define BUFF_SZ 64
     #define BUFF_SZ 64
     char printedAddr[BUFF_SZ] = {0};
     char printedAddr[BUFF_SZ] = {0};
-    int ret = uv_inet_ntop(addr->ss.ss_family, inAddr, printedAddr, BUFF_SZ - 1);
+    int ret = Rffi_inet_ntop(addr->ss.ss_family == AF_INET6, inAddr, printedAddr, BUFF_SZ - 1);
     if (ret != 0) {
     if (ret != 0) {
         return "invalid";
         return "invalid";
     }
     }
@@ -388,4 +389,4 @@ void Sockaddr_addrFromHandle(struct Sockaddr* addr, uint32_t handle)
     addr->type = Sockaddr_HANDLE;
     addr->type = Sockaddr_HANDLE;
     addr->addrLen = sizeof(struct Sockaddr);
     addr->addrLen = sizeof(struct Sockaddr);
     Bits_memcpy(&((uint8_t*)addr)[4], &handle, 4);
     Bits_memcpy(&((uint8_t*)addr)[4], &handle, 4);
-}
+}