mirror of
https://github.com/cjdelisle/cjdns
synced 2025-10-06 00:32:50 +02:00
manual merge crashey
This commit is contained in:
14
Cargo.lock
generated
14
Cargo.lock
generated
@@ -261,13 +261,6 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cjdroute"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cjdns_sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.0.3"
|
||||
@@ -1003,13 +996,6 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "testcjdroute"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cjdns_sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
|
@@ -1,10 +1,5 @@
|
||||
[workspace]
|
||||
|
||||
members = [
|
||||
"rust/cjdns_sys",
|
||||
"rust/cjdroute",
|
||||
"rust/testcjdroute",
|
||||
]
|
||||
members = ["rust/cjdns_sys"]
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
11
README.md
11
README.md
@@ -52,7 +52,7 @@ scalability issues that plague existing networks.
|
||||
|
||||
## 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.
|
||||
* [/r/darknetplan][]
|
||||
* [#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
|
||||
|
||||
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:
|
||||
|
||||
systemctl start cjdns
|
||||
@@ -224,14 +224,14 @@ Then Follow the steps below:
|
||||
|
||||
*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:
|
||||
|
||||
git clone https://github.com/cjdelisle/cjdns.git cjdns
|
||||
cd cjdns
|
||||
|
||||
##### 2. Build
|
||||
### 2. Build
|
||||
|
||||
./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
|
||||
possible security issue is really a security issue.
|
||||
|
||||
That time of year again... Time for some open source Projects!
|
||||
[](https://hacktoberfest.digitalocean.com/)
|
||||
|
||||
[IRC Web]: http://chat.efnet.org/irc.cgi?chan=%23cjdns
|
||||
[Hyperboria]: https://hyperboria.net
|
||||
[/r/darknetplan]: https://www.reddit.com/r/darknetplan
|
||||
|
@@ -8,6 +8,7 @@
|
||||
[繁體中文](README_ZHT.md)
|
||||
[Español](README_ES.md)
|
||||
[Français](README_FR.md)
|
||||
[Português brasileiro](README_PT-BR.md)
|
||||
|
||||
#### *Netzwerk neu erfunden*
|
||||
|
||||
|
@@ -1,13 +1,14 @@
|
||||
# cjdns
|
||||
|
||||
[English](README.md)
|
||||
[Русская версия](README_RU.md)
|
||||
[Hrvatski](README_HR.md)
|
||||
[Svenska](README_SV.md)
|
||||
[Ελληνικά](README_GR.md)
|
||||
[Deutsch](README_DE.md)
|
||||
[繁體中文](README_ZHT.md)
|
||||
[Español](README_ES.md)
|
||||
[Français](README_FR.md)
|
||||
[Português brasileiro](README_PT-BR.md)
|
||||
|
||||
#### *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
|
||||
problemas de seguridad y escalabilidad que plagan a las redes existentes.
|
||||
|
||||
[](https://travis-ci.org/cjdelisle/cjdns)
|
||||
[](https://travis-ci.org/cjdelisle/cjdns)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/387)
|
||||
[](https://tip4commit.com/github/cjdelisle/cjdns)
|
||||
[](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
|
||||
|
@@ -2,6 +2,7 @@ Traduction à partir de la version
|
||||
[`cjdns-v19.1`](https://github.com/woshilapin/cjdns/blob/cjdns-v19.1/README.md)
|
||||
# cjdns
|
||||
|
||||
[English](README.md)
|
||||
[Русская версия](README_RU.md)
|
||||
[Hrvatski](README_HR.md)
|
||||
[Svenska](README_SV.md)
|
||||
@@ -9,7 +10,7 @@ Traduction à partir de la version
|
||||
[Deutsch](README_DE.md)
|
||||
[繁體中文](README_ZHT.md)
|
||||
[Español](README_ES.md)
|
||||
[Français](README_FR.md)
|
||||
[Português brasileiro](README_PT-BR.md)
|
||||
|
||||
#### *Le réseau réinventé*
|
||||
|
||||
|
106
README_GR.md
106
README_GR.md
@@ -8,6 +8,7 @@
|
||||
[繁體中文](README_ZHT.md)
|
||||
[Español](README_ES.md)
|
||||
[Français](README_FR.md)
|
||||
[Português brasileiro](README_PT-BR.md)
|
||||
|
||||
#### *Η δικτύωση επανεφευρέθηκε*
|
||||
|
||||
@@ -17,8 +18,10 @@ Cjdns υλοποιεί ένα κρυπτογραφημένο δίκτυο IPV6
|
||||
επεκτασιμότητας που μαστίζουν τα υπάρχοντα δίκτυα.
|
||||
|
||||
[](https://travis-ci.org/cjdelisle/cjdns)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/387)
|
||||
[](https://tip4commit.com/github/cjdelisle/cjdns)
|
||||
[](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
|
||||

|
||||
|
||||
## Γνώμες πελατών
|
||||
|
||||
@@ -127,11 +130,99 @@ Cjdns υλοποιεί ένα κρυπτογραφημένο δίκτυο IPV6
|
||||
|
||||
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
|
||||
|
||||
Κλωνοποίηστε το αποθετήριο από το GitHub και περάστε στο πηγαίο φάκελο:
|
||||
|
||||
git clone https://github.com/cjdelisle/cjdns.git
|
||||
git clone https://github.com/cjdelisle/cjdns.git cjdns
|
||||
cd cjdns
|
||||
|
||||
### 2. Χτίστε
|
||||
@@ -373,6 +464,19 @@ TUN/TAP συσκευή - αυτό είναι στάνταρ πρωτόκολλο
|
||||
* την **Python library**; δείτε [εδώ](contrib/python/README.md).
|
||||
* την **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
|
||||
[Hyperboria]: https://hyperboria.net
|
||||
|
@@ -8,6 +8,7 @@
|
||||
[繁體中文](README_ZHT.md)
|
||||
[Español](README_ES.md)
|
||||
[Français](README_FR.md)
|
||||
[Português brasileiro](README_PT-BR.md)
|
||||
|
||||
#### *Umrežavanje iznova*
|
||||
|
||||
@@ -17,7 +18,10 @@ mrežnu konfiguraciju i sprječava mnoge sigurnosne i
|
||||
skalabilne probleme koje muče trenutne mreže.
|
||||
|
||||
[](https://travis-ci.org/cjdelisle/cjdns)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/387)
|
||||
[](https://tip4commit.com/github/cjdelisle/cjdns)
|
||||
[](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
|
||||

|
||||
|
||||
## Iskustva
|
||||
|
||||
@@ -38,7 +42,7 @@ skalabilne probleme koje muče trenutne mreže.
|
||||
|
||||
## Zajednica
|
||||
|
||||
* irc://irc.efnet.org/#cjdns ([web client][IRC Web])
|
||||
* [irc://irc.efnet.org/#cjdns][IRC Web]
|
||||
* [Hyperboria][]
|
||||
* [Projekt Meshnet][]
|
||||
* [/r/darknetplan][]
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# cjdns
|
||||
|
||||
[English](README.md)
|
||||
[Русская версия](README_RU.md)
|
||||
[Hrvatski](README_HR.md)
|
||||
[Svenska](README_SV.md)
|
||||
@@ -8,13 +9,12 @@
|
||||
[繁體中文](README_ZHT.md)
|
||||
[Español](README_ES.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
|
||||
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.
|
||||
|
||||
[](https://travis-ci.org/cjdelisle/cjdns)
|
||||
@@ -63,7 +63,7 @@ problemas de escalabilidade que afetam as redes existentes.
|
||||
|
||||
* [Objetivos do projeto](doc/projectGoals.md)
|
||||
* [Cjdns Whitepaper](doc/Whitepaper.md)
|
||||
* [Cjdns na Wikipedia][]
|
||||
* [Cjdns na Wikipedia](https://fr.wikipedia.org/wiki/Cjdns)
|
||||
|
||||
Configuração avançada:
|
||||
|
||||
|
@@ -8,13 +8,17 @@
|
||||
[繁體中文](README_ZHT.md)
|
||||
[Español](README_ES.md)
|
||||
[Français](README_FR.md)
|
||||
[Português brasileiro](README_PT-BR.md)
|
||||
|
||||
Безопасная, зашифрованная сеть для обычных людей.
|
||||
|
||||
Cjdns — это зашифрованная IPv6 сеть, в которой используются публичные ключи шифрования для присвоения публичного адреса и распределённой таблицы маршрутизации (DHT). Это позволяет создавать сети с очень простой настройкой, которые будут защищены от потенциальных проблем ныне существующих IPv4 и IPv6 сетей.
|
||||
|
||||
[](https://travis-ci.org/cjdelisle/cjdns)
|
||||
[](https://tip4commit.com/github/cjdelisle/cjdns)
|
||||
[](https://travis-ci.org/cjdelisle/cjdns)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/387)
|
||||
[](https://tip4commit.com/github/cjdelisle/cjdns)
|
||||
[](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
|
||||

|
||||
|
||||
## Рекомендательные письма
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
[繁體中文](README_ZHT.md)
|
||||
[Español](README_ES.md)
|
||||
[Français](README_FR.md)
|
||||
[Português brasileiro](README_PT-BR.md)
|
||||
|
||||
#### *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
|
||||
många skalnings- och säkerhetsproblem som andra nätverk har.
|
||||
|
||||
[](https://travis-ci.org/cjdelisle/cjdns)
|
||||
[](https://travis-ci.org/cjdelisle/cjdns)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/387)
|
||||
[](https://tip4commit.com/github/cjdelisle/cjdns)
|
||||
[](https://kiwiirc.com/client/irc.efnet.org/?nick=visitor|?#cjdns)
|
||||

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

|
||||
|
||||
## 評價
|
||||
|
||||
|
@@ -157,7 +157,7 @@ static int checkAddress(struct Admin_pvt* admin, int index, uint64_t now)
|
||||
static void clearExpiredAddresses(void* 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;
|
||||
for (int i = admin->map.count - 1; i >= 0; i--) {
|
||||
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.
|
||||
if (!admin->currentRequest) {
|
||||
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)) {
|
||||
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");
|
||||
cookie = (cookieInt) ? *cookieInt : 0;
|
||||
}
|
||||
uint64_t nowSecs = Time_currentTimeSeconds(admin->eventBase);
|
||||
uint64_t nowSecs = Time_currentTimeSeconds();
|
||||
String* submittedHash = Dict_getStringC(message, "hash");
|
||||
if (cookie > nowSecs || cookie < nowSecs - 20 || !submittedHash || submittedHash->len != 64) {
|
||||
return false;
|
||||
@@ -345,7 +345,7 @@ static void handleRequest(Dict* messageDict,
|
||||
//Log_debug(admin->logger, "Got a request for a cookie");
|
||||
Dict* d = Dict_new(allocator);
|
||||
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 };
|
||||
Dict_putString(d, cookie, theCookie, allocator);
|
||||
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
|
||||
// asynchronous messages.
|
||||
int index = Map_LastMessageTimeByAddr_indexForKey(&src, &admin->map);
|
||||
uint64_t now = Time_currentTimeMilliseconds(admin->eventBase);
|
||||
uint64_t now = Time_currentTimeMilliseconds();
|
||||
admin->asyncEnabled = 1;
|
||||
if (index >= 0) {
|
||||
admin->map.values[index]->timeOfLastMessage = now;
|
||||
|
@@ -123,7 +123,7 @@ static Dict* makeLogMessage(struct Subscription* subscription,
|
||||
String* message,
|
||||
struct Allocator* alloc)
|
||||
{
|
||||
int64_t now = (int64_t) Time_currentTimeSeconds(logger->base);
|
||||
int64_t now = (int64_t) Time_currentTimeSeconds();
|
||||
|
||||
Dict* out = Dict_new(alloc);
|
||||
|
||||
|
@@ -147,5 +147,5 @@ for i in $(seq 1 100); do
|
||||
export CARGO_TARGET_ARMV7A_LINUX_ANDROIDEABI_LINKER=$CC
|
||||
|
||||
echo "Compiler CC: $CC - $(${CC} --version)"
|
||||
cargo build --release -vv --target "$RUST_TARGET"
|
||||
cargo build --release -v --target "$RUST_TARGET"
|
||||
done
|
@@ -6,7 +6,7 @@ Tested on ubuntu 18.04LTS
|
||||
git clone https://github.com/cjdelisle/cjdns.git
|
||||
cd cjdns/
|
||||
./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`.
|
||||
|
@@ -7,4 +7,5 @@ cp publictoip6 /usr/bin/
|
||||
cp randombytes /usr/bin/
|
||||
cp sybilsim /usr/bin/
|
||||
cp contrib/systemd/cjdns.service /etc/systemd/system/
|
||||
cp contrib/systemd/cjdns-resume.service /etc/systemd/system
|
||||
systemctl enable --now cjdns.service
|
||||
|
@@ -325,7 +325,7 @@ static void resetIfTimeout(struct CryptoAuth_Session_pvt* session)
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t nowSecs = Time_currentTimeSeconds(session->context->eventBase);
|
||||
uint64_t nowSecs = Time_currentTimeSeconds();
|
||||
if (nowSecs - session->timeOfLastPacket < session->setupResetAfterInactivitySeconds) {
|
||||
return;
|
||||
} 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. */
|
||||
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,
|
||||
@@ -1105,7 +1105,7 @@ struct CryptoAuth_Session* CryptoAuth_newSession(struct CryptoAuth* ca,
|
||||
session->context = context;
|
||||
session->requireAuth = requireAuth;
|
||||
session->displayName = displayName ? String_new(displayName, alloc) : NULL;
|
||||
session->timeOfLastPacket = Time_currentTimeSeconds(context->eventBase);
|
||||
session->timeOfLastPacket = Time_currentTimeSeconds();
|
||||
session->alloc = alloc;
|
||||
|
||||
session->resetAfterInactivitySeconds = CryptoAuth_DEFAULT_RESET_AFTER_INACTIVITY_SECONDS;
|
||||
|
@@ -101,7 +101,7 @@ struct Janitor_Search
|
||||
|
||||
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++) {
|
||||
struct Janitor_Blacklist* qp = &j->blacklist[i];
|
||||
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)
|
||||
{
|
||||
int64_t now = Time_currentTimeMilliseconds(j->eventBase);
|
||||
int64_t now = Time_currentTimeMilliseconds();
|
||||
int oldestIndex = 0;
|
||||
int64_t oldestTime = INT64_MAX;
|
||||
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);
|
||||
|
||||
uint64_t now = Time_currentTimeMilliseconds(janitor->eventBase);
|
||||
uint64_t now = Time_currentTimeMilliseconds();
|
||||
|
||||
uint64_t nextTimeout = (janitor->pub.localMaintainenceMilliseconds / 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.blacklistPathForMilliseconds = Janitor_BLACKLIST_PATH_FOR_MILLISECONDS_DEFAULT;
|
||||
|
||||
janitor->timeOfNextGlobalMaintainence = Time_currentTimeMilliseconds(eventBase);
|
||||
janitor->timeOfNextGlobalMaintainence = Time_currentTimeMilliseconds();
|
||||
|
||||
janitor->timeout = Timeout_setTimeout(maintanenceCycle,
|
||||
janitor,
|
||||
|
@@ -622,7 +622,7 @@ static struct Node_Link* linkNodes(struct Node_Two* parent,
|
||||
link->parent = parent;
|
||||
link->discoveredPath = discoveredPath;
|
||||
link->linkCost = 0;
|
||||
link->timeLastSeen = Time_currentTimeMilliseconds(store->eventBase);
|
||||
link->timeLastSeen = Time_currentTimeMilliseconds();
|
||||
Identity_set(link);
|
||||
|
||||
// reverse link
|
||||
@@ -1358,7 +1358,7 @@ static struct Node_Link* discoverNode(struct NodeStore_pvt* store,
|
||||
child->alloc = alloc;
|
||||
Bits_memcpy(&child->address, addr, sizeof(struct Address));
|
||||
child->encodingScheme = EncodingScheme_clone(scheme, child->alloc);
|
||||
child->timeLastPinged = Time_currentTimeMilliseconds(store->eventBase);
|
||||
child->timeLastPinged = Time_currentTimeMilliseconds();
|
||||
Identity_set(child);
|
||||
}
|
||||
|
||||
@@ -1393,7 +1393,7 @@ static struct Node_Link* discoverNode(struct NodeStore_pvt* store,
|
||||
} while (firstHopInPath_INVALID != path);
|
||||
|
||||
if (lastLink && LabelSplicer_routesThrough(addr->path, lastLink->child->address.path)) {
|
||||
// checking for sillyness...
|
||||
// checking for silliness...
|
||||
Assert_true(lastLink != store->selfLink);
|
||||
NodeStore_unlinkNodes(&store->pub, lastLink);
|
||||
continue;
|
||||
@@ -1639,7 +1639,7 @@ struct NodeStore* NodeStore_new(struct Address* myAddress,
|
||||
Identity_set(selfNode);
|
||||
out->pub.selfNode = selfNode;
|
||||
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->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;
|
||||
uint64_t pathFrag = path;
|
||||
uint64_t now = Time_currentTimeMilliseconds(store->eventBase);
|
||||
uint64_t now = Time_currentTimeMilliseconds();
|
||||
for (;;) {
|
||||
struct Node_Link* nextLink = NULL;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
struct Node_Link* link = Node_getBestParent(node);
|
||||
while (link && link != store->selfLink) {
|
||||
|
@@ -466,7 +466,7 @@ static int handleIncoming(struct DHTMessage* message, void* vcontext)
|
||||
|
||||
struct RouterModule* module = Identity_check((struct RouterModule*) vcontext);
|
||||
|
||||
// This is retreived below by onResponseOrTimeout()
|
||||
// This is retrieved below by onResponseOrTimeout()
|
||||
module->currentMessage = message;
|
||||
Pinger_pongReceived(txid, module->pinger);
|
||||
module->currentMessage = NULL;
|
||||
|
@@ -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
|
||||
be used by the recipient to prefix CryptoAuth data packets sent after that),
|
||||
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
|
||||
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.
|
||||
* `tar` (byte string): the target address. If provided, contains an address
|
||||
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.
|
||||
|
||||
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
|
||||
nonces before the highest nonce received so far.
|
||||
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
|
||||
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.
|
||||
@@ -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
|
||||
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).
|
||||
|
||||
##### AuthType Two
|
||||
|
@@ -74,6 +74,12 @@ Now enter the ip6tables rules:
|
||||
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 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:
|
||||
|
||||
|
@@ -308,7 +308,7 @@ static void onPingResponse(struct SwitchPinger_Response* resp, void* onResponseC
|
||||
sendPeer(0xffffffff, PFChan_Core_PEER, ep, resp->milliseconds);
|
||||
}
|
||||
|
||||
ep->timeOfLastPing = Time_currentTimeMilliseconds(ic->eventBase);
|
||||
ep->timeOfLastPing = Time_currentTimeMilliseconds();
|
||||
|
||||
if (Defined(Log_DEBUG)) {
|
||||
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)
|
||||
{
|
||||
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.
|
||||
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);
|
||||
|
||||
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
|
||||
}
|
||||
@@ -701,10 +701,10 @@ static Iface_DEFUN handleBeacon(
|
||||
// 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".
|
||||
ep->timeOfLastMessage =
|
||||
Time_currentTimeMilliseconds(ic->eventBase) - ic->pingAfterMilliseconds - 1;
|
||||
Time_currentTimeMilliseconds() - ic->pingAfterMilliseconds - 1;
|
||||
|
||||
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
|
||||
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
|
||||
// (now - pingAfterMilliseconds - 1) so it will be considered a "lazy node".
|
||||
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",
|
||||
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");
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
int caState = Ca_getState(ep->caSession);
|
||||
@@ -872,7 +872,7 @@ static Iface_DEFUN afterDecrypt(struct Message* msg, struct Iface* plaintext)
|
||||
if (ep->state != caState) {
|
||||
sendPeer(0xffffffff, PFChan_Core_PEER, ep, 0xffff);
|
||||
}
|
||||
ep->timeOfLastMessage = Time_currentTimeMilliseconds(ic->eventBase);
|
||||
ep->timeOfLastMessage = Time_currentTimeMilliseconds();
|
||||
}
|
||||
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
|
||||
// (now - pingAfterMilliseconds - 1) so it will be considered a "lazy node".
|
||||
ep->timeOfLastMessage =
|
||||
Time_currentTimeMilliseconds(ic->eventBase) - ic->pingAfterMilliseconds - 1;
|
||||
Time_currentTimeMilliseconds() - ic->pingAfterMilliseconds - 1;
|
||||
|
||||
if (Defined(Log_INFO)) {
|
||||
struct Allocator* tempAlloc = Allocator_child(ep->alloc);
|
||||
@@ -1087,7 +1087,7 @@ int InterfaceController_getPeerStats(struct InterfaceController* ifController,
|
||||
struct InterfaceController_PeerStats* stats =
|
||||
Allocator_calloc(alloc, sizeof(struct InterfaceController_PeerStats), count);
|
||||
|
||||
uint32_t now = Time_currentTimeMilliseconds(ic->eventBase);
|
||||
uint32_t now = Time_currentTimeMilliseconds();
|
||||
int xcount = 0;
|
||||
for (int j = 0; j < ic->icis->length; j++) {
|
||||
struct InterfaceController_Iface_pvt* ici = ArrayList_OfIfaces_get(ic->icis, j);
|
||||
|
@@ -210,7 +210,7 @@ struct SessionManager_HandleList* SessionManager_getHandleList(struct SessionMan
|
||||
static uint32_t effectiveMetric(struct SessionManager_pvt* sm,
|
||||
SessionManager_Path_t* path)
|
||||
{
|
||||
int64_t x = Time_currentTimeMilliseconds(sm->eventBase) - path->timeLastValidated;
|
||||
int64_t x = Time_currentTimeMilliseconds() - path->timeLastValidated;
|
||||
x += path->metric;
|
||||
return (x > Metric_NO_INFO) ? Metric_NO_INFO : x;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ static bool discoverPath(struct SessionManager_Session_pvt* sess,
|
||||
return false;
|
||||
}
|
||||
SessionManager_Path_t* path = pathForLabel(sess, label);
|
||||
uint64_t now = Time_currentTimeMilliseconds(sess->sessionManager->eventBase);
|
||||
uint64_t now = Time_currentTimeMilliseconds();
|
||||
if (path) {
|
||||
if (metric != Metric_DEAD_LINK && effectiveMetric(sess->sessionManager, path) <= metric) {
|
||||
// already have a better source of truth
|
||||
@@ -453,7 +453,7 @@ static struct SessionManager_Session_pvt* getSession(struct SessionManager_pvt*
|
||||
printedIp6, sess->pub.receiveHandle);
|
||||
}
|
||||
|
||||
int64_t now = Time_currentTimeMilliseconds(sm->eventBase);
|
||||
int64_t now = Time_currentTimeMilliseconds();
|
||||
sess->alloc = alloc;
|
||||
sess->sessionManager = sm;
|
||||
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++) {
|
||||
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; }
|
||||
Map_BufferedMessages_remove(i, &sm->bufMap);
|
||||
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--) {
|
||||
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...
|
||||
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);
|
||||
buffered->msg = msg;
|
||||
buffered->alloc = lookupAlloc;
|
||||
buffered->timeSentMilliseconds = Time_currentTimeMilliseconds(sm->eventBase);
|
||||
buffered->timeSentMilliseconds = Time_currentTimeMilliseconds();
|
||||
Allocator_adopt(lookupAlloc, Message_getAlloc(msg));
|
||||
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)) {
|
||||
// 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); }
|
||||
|
@@ -144,7 +144,7 @@ module.exports.generate = function (builder, isSubnode, callback) {
|
||||
//console.log(test);
|
||||
const testProto = /^.*\/([^\/]+)\.c$/.exec(test)[1];
|
||||
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) {
|
||||
cflags.push(
|
||||
'-D', 'CJDNS_FUZZ_INIT='+testProto+'_FUZZ_INIT',
|
||||
|
@@ -54,7 +54,8 @@ export type Builder_t = {|
|
||||
lintFiles: (Builder_Linter_t)=>void,
|
||||
config: Builder_Config_t,
|
||||
tmpFile: (?string)=>string,
|
||||
compilerType: () => Builder_Compiler_t
|
||||
compilerType: () => Builder_Compiler_t,
|
||||
fileCflags: {[string]: string[]},
|
||||
|};
|
||||
export type Builder_BaseConfig_t = {|
|
||||
systemName?: ?string,
|
||||
@@ -70,7 +71,6 @@ export type Builder_Config_t = {
|
||||
ldflags: string[],
|
||||
libs: string[],
|
||||
jobs: number,
|
||||
fileCflags: {[string]: string[]},
|
||||
} & {[string]:any};
|
||||
import type { Nthen_WaitFor_t } from 'nthen';
|
||||
import type { Saferphore_t } from 'saferphore';
|
||||
@@ -80,6 +80,14 @@ export type Builder_CompileJob_t = {
|
||||
outputFile: ?string,
|
||||
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 = {
|
||||
buildStage: Builder_Stage_t,
|
||||
testStage: Builder_Stage_t,
|
||||
@@ -256,6 +264,8 @@ const finalizeCtx = function (
|
||||
|
||||
compilerType: () => JSON.parse(JSON.stringify(ctx.state.compilerType)),
|
||||
|
||||
fileCflags: {},
|
||||
|
||||
}) /*:Builder_t*/);
|
||||
return ctx;
|
||||
};
|
||||
@@ -431,7 +441,7 @@ const getExeFile = function (ctx, exe /*:Builder_CompileJob_t*/) {
|
||||
const getFlags = function (ctx, cFile, includeDirs) {
|
||||
const flags = [];
|
||||
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) {
|
||||
for (let i = 0; i < ctx.config.includeDirs.length; i++) {
|
||||
if (flags[flags.indexOf(ctx.config.includeDirs[i])-1] === '-I') {
|
||||
@@ -766,7 +776,7 @@ const sweep = (path, done) => {
|
||||
module.exports.configure = function (
|
||||
params /*:Builder_BaseConfig_t*/,
|
||||
configFunc /*:(Builder_t, Nthen_WaitFor_t)=>void*/
|
||||
) {
|
||||
) /*:Builder_Pub_t*/ {
|
||||
|
||||
// Track time taken for various steps
|
||||
const time = makeTime();
|
||||
@@ -819,7 +829,6 @@ module.exports.configure = function (
|
||||
cflags: [],
|
||||
ldflags: [],
|
||||
libs: [],
|
||||
fileCflags: {},
|
||||
jobs,
|
||||
},
|
||||
};
|
||||
|
@@ -20,7 +20,7 @@ main()
|
||||
JSHINT="`pwd`/node_modules/jshint/bin/jshint"
|
||||
|
||||
echo "Running JSHint..."
|
||||
${JSHINT} --config node_build/.jshintrc \
|
||||
${JSHINT} --config .jshintrc \
|
||||
--exclude-path .jshintignore \
|
||||
--reporter node_build/JSHintReporter.js . || return 1
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
/**
|
||||
* 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 */
|
||||
|
@@ -1,6 +1,7 @@
|
||||
//! Message type.
|
||||
|
||||
use std::slice::{from_raw_parts, from_raw_parts_mut};
|
||||
use std::i32;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
|
@@ -1,9 +1,6 @@
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use std::os::raw::{c_char, c_int};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bytestring::ByteString;
|
||||
use crate::cffi::{self, Allocator_t, Random_t, String_t};
|
||||
use crate::crypto::crypto_auth;
|
||||
@@ -14,6 +11,11 @@ use crate::external::interface::cif;
|
||||
use crate::external::memory::allocator;
|
||||
use crate::rtypes::*;
|
||||
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
|
||||
|
||||
@@ -382,4 +384,78 @@ pub unsafe extern "C" fn Rffi_printError(
|
||||
.flatten()
|
||||
.map(|e|str_to_c(&format!("{:?}", e), alloc))
|
||||
.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
|
||||
}
|
||||
|
@@ -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" }
|
@@ -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" }
|
@@ -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" }
|
@@ -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" }
|
@@ -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" }
|
@@ -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" }
|
@@ -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" }
|
@@ -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" }
|
@@ -240,7 +240,7 @@ struct ReachabilityAnnouncer_pvt
|
||||
|
||||
static int64_t ourTime(struct ReachabilityAnnouncer_pvt* rap)
|
||||
{
|
||||
uint64_t now = Time_currentTimeMilliseconds(rap->base);
|
||||
uint64_t now = Time_currentTimeMilliseconds();
|
||||
Assert_true(!(now >> 63));
|
||||
return (int64_t) now;
|
||||
}
|
||||
|
@@ -203,7 +203,7 @@ static void latencyUpdate(
|
||||
//Log_debug(rcp->log, "Latency update for [%" PRIx64 "] [%u]ms", pip->pub.addr.path, lag);
|
||||
pip->sumOfLag += lag;
|
||||
pip->lagSamples++;
|
||||
pip->timeOfLastLagUpdate = Time_currentTimeMilliseconds(rcp->base);
|
||||
pip->timeOfLastLagUpdate = Time_currentTimeMilliseconds();
|
||||
}
|
||||
|
||||
static void onReplyOld(Dict* msg, struct Address* src, struct MsgCore_Promise* prom)
|
||||
|
@@ -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);
|
||||
Identity_set(q);
|
||||
q->snp = snp;
|
||||
q->sendTime = Time_currentTimeMilliseconds(snp->base);
|
||||
q->sendTime = Time_currentTimeMilliseconds();
|
||||
|
||||
Dict* msg = qp->msg = Dict_new(qp->alloc);
|
||||
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);
|
||||
Identity_set(q);
|
||||
q->snp = snp;
|
||||
q->sendTime = Time_currentTimeMilliseconds(snp->base);
|
||||
q->sendTime = Time_currentTimeMilliseconds();
|
||||
|
||||
Dict* msg = qp->msg = Dict_new(qp->alloc);
|
||||
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);
|
||||
Identity_set(q);
|
||||
q->snp = snp;
|
||||
q->sendTime = Time_currentTimeMilliseconds(snp->base);
|
||||
q->sendTime = Time_currentTimeMilliseconds();
|
||||
|
||||
Dict* msg = qp->msg = Dict_new(qp->alloc);
|
||||
qp->cb = onReply;
|
||||
@@ -454,7 +454,7 @@ struct SupernodeHunter* SupernodeHunter_new(struct Allocator* allocator,
|
||||
out->base = base;
|
||||
//out->rand = rand;
|
||||
//out->nodes = AddrSet_new(alloc);
|
||||
//out->timeSnodeCalled = Time_currentTimeMilliseconds(base);
|
||||
//out->timeSnodeCalled = Time_currentTimeMilliseconds();
|
||||
//out->snodeCandidates = AddrSet_new(alloc);
|
||||
out->log = log;
|
||||
out->alloc = alloc;
|
||||
|
@@ -87,7 +87,7 @@ static Iface_DEFUN incomingTunA(struct Message* msg, struct Iface* tunA)
|
||||
|
||||
static void notLinkedYet(struct TwoNodes* ctx)
|
||||
{
|
||||
uint64_t now = Time_currentTimeMilliseconds(ctx->base);
|
||||
uint64_t now = Time_currentTimeMilliseconds();
|
||||
if ((now - ctx->startTime) > 5000) {
|
||||
Assert_failure("Failed to link in 5 seconds");
|
||||
}
|
||||
@@ -172,7 +172,7 @@ static void start(struct Allocator* alloc,
|
||||
out->logger = logger;
|
||||
out->checkLinkageTimeout = Timeout_setInterval(checkLinkage, out, 1, base, alloc);
|
||||
out->base = base;
|
||||
out->startTime = Time_currentTimeMilliseconds(base);
|
||||
out->startTime = Time_currentTimeMilliseconds();
|
||||
out->runTest = runTest;
|
||||
out->alloc = alloc;
|
||||
|
||||
|
@@ -59,7 +59,7 @@ static Iface_DEFUN incomingTun(struct Message* msg, struct Iface* tunB)
|
||||
|
||||
static void notLinkedYet(struct Context* ctx)
|
||||
{
|
||||
uint64_t now = Time_currentTimeMilliseconds(ctx->base);
|
||||
uint64_t now = Time_currentTimeMilliseconds();
|
||||
if ((now - ctx->startTime) > 5000) {
|
||||
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->checkLinkageTimeout = Timeout_setInterval(checkLinkage, ctx, 1, base, alloc);
|
||||
ctx->base = base;
|
||||
ctx->startTime = Time_currentTimeMilliseconds(base);
|
||||
ctx->startTime = Time_currentTimeMilliseconds();
|
||||
ctx->alloc = alloc;
|
||||
|
||||
Log_debug(a->logger, "Waiting for nodes to link asynchronously...");
|
||||
|
@@ -22,7 +22,7 @@ Linker_require("util/ArrayList.c")
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
@@ -30,7 +30,7 @@ struct AverageRoller* AverageRoller_new(const uint32_t windowSeconds,
|
||||
Bits_memcpy(roller, (&(struct AverageRoller_pvt) {
|
||||
.windowSeconds = windowSeconds,
|
||||
.eventBase = eventBase,
|
||||
.lastUpdateTime = (uint32_t) Time_currentTimeSeconds(eventBase)
|
||||
.lastUpdateTime = (uint32_t) Time_currentTimeSeconds()
|
||||
}), sizeof(struct AverageRoller_pvt));
|
||||
|
||||
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);
|
||||
return AverageRoller_updateAtTime(averageRoller,
|
||||
Time_currentTimeSeconds(roller->eventBase),
|
||||
Time_currentTimeSeconds(),
|
||||
newEntry);
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ struct Pinger
|
||||
|
||||
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);
|
||||
|
||||
// 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.
|
||||
return;
|
||||
}
|
||||
int64_t now = Time_currentTimeMilliseconds(p->pinger->eventBase);
|
||||
int64_t now = Time_currentTimeMilliseconds();
|
||||
long long diff = ((long long) now) - ((long long)p->timeSent);
|
||||
Assert_true(diff < 1000000000);
|
||||
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,
|
||||
.pinger = pinger,
|
||||
.timeSent = Time_currentTimeMilliseconds(pinger->eventBase),
|
||||
.timeSent = Time_currentTimeMilliseconds(),
|
||||
.onResponse = onResponse
|
||||
}));
|
||||
Identity_set(ping);
|
||||
|
@@ -24,7 +24,7 @@ Linker_require("util/Set.c")
|
||||
|
||||
/*
|
||||
* 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_Iter;
|
||||
|
@@ -25,10 +25,9 @@ Linker_require("util/events/libuv/Time.c")
|
||||
uint64_t Time_hrtime(void);
|
||||
|
||||
// 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.
|
||||
uint64_t Time_currentTimeSeconds(struct EventBase* eventBase);
|
||||
uint64_t Time_currentTimeSeconds(void);
|
||||
|
||||
#endif
|
||||
|
@@ -12,22 +12,21 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* 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/libuv/EventBase_pvt.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -11,8 +11,17 @@ module.exports = (builder, js) => {
|
||||
'src/uv-common.h',
|
||||
'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') {
|
||||
cflags.push(
|
||||
'-D_WIN32_WINNT=0x0600',
|
||||
'-D_GNU_SOURCE',
|
||||
)
|
||||
files.push(
|
||||
'include/uv-win.h',
|
||||
'src/win/async.c',
|
||||
@@ -50,6 +59,10 @@ module.exports = (builder, js) => {
|
||||
'src/win/winsock.h',
|
||||
);
|
||||
} else {
|
||||
cflags.push(
|
||||
'-D_LARGEFILE_SOURCE',
|
||||
'-D_FILE_OFFSET_BITS=64',
|
||||
);
|
||||
files.push(
|
||||
'include/uv-unix.h',
|
||||
'include/uv-linux.h',
|
||||
@@ -84,6 +97,7 @@ module.exports = (builder, js) => {
|
||||
files.push('src/unix/proctitle.c');
|
||||
}
|
||||
if (builder.config.systemName === 'darwin') {
|
||||
cflags.push('-D_DARWIN_USE_64_BIT_INODE=1');
|
||||
files.push(
|
||||
'src/unix/darwin.c',
|
||||
'src/unix/fsevents.c',
|
||||
@@ -91,6 +105,7 @@ module.exports = (builder, js) => {
|
||||
);
|
||||
}
|
||||
if (builder.config.systemName === 'linux') {
|
||||
cflags.push('-D_POSIX_C_SOURCE=200112');
|
||||
files.push(
|
||||
'src/unix/linux-core.c',
|
||||
'src/unix/linux-inotify.c',
|
||||
@@ -115,7 +130,10 @@ module.exports = (builder, js) => {
|
||||
for (f of files) {
|
||||
if (f.endsWith(".c")) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* 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 "memory/Allocator.h"
|
||||
#include "util/platform/Sockaddr.h"
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
struct Sockaddr_pvt
|
||||
{
|
||||
@@ -138,7 +139,7 @@ int Sockaddr_parse(const char* input, struct Sockaddr_storage* out)
|
||||
if (lastColon != firstColon) {
|
||||
// ipv6
|
||||
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;
|
||||
}
|
||||
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;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
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
|
||||
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) {
|
||||
return "invalid";
|
||||
}
|
||||
@@ -388,4 +389,4 @@ void Sockaddr_addrFromHandle(struct Sockaddr* addr, uint32_t handle)
|
||||
addr->type = Sockaddr_HANDLE;
|
||||
addr->addrLen = sizeof(struct Sockaddr);
|
||||
Bits_memcpy(&((uint8_t*)addr)[4], &handle, 4);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user