This repository has been archived by the owner on Oct 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5711d10
Showing
27 changed files
with
6,516 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.o | ||
dnsseed* | ||
dnsstats.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Contributing | ||
|
||
When contributing to this repository, please first discuss the change you wish to make via issue, | ||
email, or any other method with the owners of this repository before making a change. | ||
|
||
Please note we have a code of conduct, please follow it in all your interactions with the project. | ||
|
||
## Pull Request Process | ||
|
||
1. Ensure any install or build dependencies are removed before the end of the layer when doing a | ||
build. | ||
2. Update the README.md with details of changes to the interface, this includes new environment | ||
variables, exposed ports, useful file locations and container parameters. | ||
3. Increase the version numbers in any examples files and the README.md to the new version that this | ||
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). | ||
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you | ||
do not have permission to do that, you may request the second reviewer to merge it for you. | ||
|
||
## Code of Conduct | ||
|
||
### Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, gender identity and expression, level of experience, | ||
nationality, personal appearance, race, religion, or sexual identity and | ||
orientation. | ||
|
||
### Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment | ||
include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or | ||
advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic | ||
address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
### Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
### Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an appointed | ||
representative at an online or offline event. Representation of a project may be | ||
further defined and clarified by project maintainers. | ||
|
||
### Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the project team at [email protected]. All | ||
complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. The project team is | ||
obligated to maintain confidentiality with regard to the reporter of an incident. | ||
Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
### Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, | ||
available at [http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM debian:stretch-slim as build | ||
|
||
# Install our build dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
build-essential \ | ||
libboost-all-dev \ | ||
libssl-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY . /usr/local/src | ||
|
||
WORKDIR /usr/local/src | ||
|
||
RUN make | ||
|
||
FROM debian:stretch-slim | ||
|
||
# Install our run dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
build-essential \ | ||
libboost-all-dev \ | ||
libssl-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /usr/local/bin | ||
|
||
COPY --from=build /usr/local/src/litecoinz-seed . | ||
|
||
EXPOSE 53 | ||
EXPOSE 53/udp | ||
|
||
ENTRYPOINT ["./litecoinz-seed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 LiteCoinZ | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CXXFLAGS = -O3 -g0 -march=native | ||
LDFLAGS = $(CXXFLAGS) | ||
|
||
litecoinz-seeder: dns.o litecoinz.o netbase.o protocol.o db.o main.o util.o | ||
g++ -pthread $(LDFLAGS) -o litecoinz-seeder dns.o litecoinz.o netbase.o protocol.o db.o main.o util.o -lcrypto | ||
|
||
%.o: %.cpp litecoinz.h netbase.h protocol.h db.h serialize.h uint256.h util.h | ||
g++ -std=c++11 -pthread $(CXXFLAGS) -Wno-unused -Wno-sign-compare -Wno-reorder -Wno-comment -c -o $@ $< | ||
|
||
dns.o: dns.c | ||
gcc -pthread -std=c99 $(CXXFLAGS) dns.c -c -o dns.o | ||
|
||
%.o: %.cpp | ||
|
||
clean: | ||
rm -f *.o litecoinz-seeder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# LitecoinZ-Seeder | ||
|
||
Litecoinz-seeder is a crawler for the LitecoinZ network, which exposes a list of reliable nodes via a built-in DNS server. | ||
|
||
Run your LitecoinZ seeder and post it in https://github.com/litecoinz-project/litecoinz/issues/1. We need a lot of seed nodes to be fully decentralized! | ||
|
||
Features: | ||
* regularly revisits known nodes to check their availability | ||
* bans nodes after enough failures, or bad behaviour | ||
* accepts nodes down to v0.3.19 to request new IP addresses from, but only reports good post-v0.3.24 nodes. | ||
* keeps statistics over (exponential) windows of 2 hours, 8 hours, 1 day and 1 week, to base decisions on. | ||
* very low memory (a few tens of megabytes) and cpu requirements. | ||
* crawlers run in parallel (by default 96 threads simultaneously). | ||
|
||
|
||
## Prerequisites | ||
|
||
``` | ||
$ sudo apt-get install build-essential libboost-all-dev libssl-dev | ||
``` | ||
|
||
## Usage | ||
|
||
Assuming you want to run a dns seed on dnsseed.example.com, you will need an authorative NS record in example.com's domain record, pointing to for example vps.example.com: | ||
|
||
``` | ||
$ dig -t NS dnsseed.example.com | ||
;; ANSWER SECTION | ||
dnsseed.example.com. 86400 IN NS vps.example.com. | ||
``` | ||
|
||
On the system vps.example.com, you can now run litecoinz-seeder: | ||
|
||
``` | ||
./litecoinz-seeder -h dnsseed.example.com -n vps.example.com | ||
``` | ||
|
||
If you want the DNS server to report SOA records, please provide an e-mail address (with the @ part replaced by .) using -m. | ||
|
||
## Compiling | ||
|
||
Compiling will require boost and ssl. On debian systems, these are provided by `libboost-dev` and `libssl-dev` respectively. | ||
|
||
``` | ||
$ make | ||
``` | ||
|
||
This will produce the `litecoinz-seeder` binary. | ||
|
||
## Running as non-root | ||
|
||
Typically, you'll need root privileges to listen to port 53 (name service). | ||
|
||
One solution is using an iptables rule (Linux only) to redirect it to a non-privileged port: | ||
|
||
``` | ||
$ iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-port 5353 | ||
``` | ||
|
||
If properly configured, this will allow you to run litecoinz-seeder in userspace, using the -p 5353 option. | ||
|
||
Alternatively, you can use the CAP_NET_BIND_SERVICE capability on Linux kernel versions greater than 2.6.24. | ||
|
||
``` | ||
$ setcap 'cap_net_bind_service=+ep' /path/to/litecoinz-seeder | ||
``` | ||
|
||
`setcap` usually comes pre-installed on most modern distributions, but is available in the `libcap2-bin` package on debian and libcap2 on RedHat. | ||
|
||
## Docker | ||
|
||
Build the docker image by running the following command: | ||
|
||
$ docker build -t ltcz/litecoinz-seeder . | ||
|
||
Run the docker image with the following command: | ||
|
||
``` | ||
$ docker run -d --name litecoinz-seeder -p 53:53/udp -p 53:53 ltcz/litecoinz-seeder -h dnsseed.example.com -n vps.example.com -m [email protected] | ||
``` | ||
|
||
Run the docker image with a restart policy: | ||
|
||
``` | ||
$ docker run -d --restart always --name litecoinz-seeder -p 53:53/udp -p 53:53 ltcz/litecoinz-seeder -h dnsseed.example.com -n vps.example.com -m [email protected] | ||
``` | ||
|
||
## Contributing | ||
|
||
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details | ||
|
||
## Security Warnings | ||
|
||
**LitecoinZ is experimental and a work-in-progress.** Use at your own risk. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
use warnings FATAL => 'all'; | ||
|
||
sub loadFile { | ||
my ($file) = @_; | ||
my %ret; | ||
my $max = 0; | ||
open FILE,$file; | ||
while (<FILE>) { | ||
my ($addr,$p2h,$p8h,$p1d,$p1w,$p1m) = split(/\s+/,$_); | ||
if ($p1m =~ /\A([1-9.]+)%\Z/) { | ||
my $x = $1*0.01; | ||
$max=$x if ($x > $max); | ||
$ret{$addr} = $x; | ||
} | ||
} | ||
for my $k (keys %ret) { | ||
$ret{$k} /= $max; | ||
} | ||
close FILE; | ||
return \%ret; | ||
} | ||
|
||
sub merge { | ||
my ($a,$b) = @_; | ||
return 1-(1-$a)*(1-$b); | ||
} | ||
|
||
sub combine { | ||
my ($f1,$f2) = @_; | ||
my %ret; | ||
for my $k1 (keys %{$f1}) { | ||
if (defined $f2->{$k1}) { | ||
$ret{$k1} = merge($f1->{$k1}, $f2->{$k1}); | ||
} else { | ||
$ret{$k1} = merge($f1->{$k1}, 0); | ||
} | ||
} | ||
for my $k2 (keys %{$f2}) { | ||
if (!defined $f1->{$k2}) { | ||
$ret{$k2} = merge(0, $f2->{$k2}); | ||
} | ||
} | ||
return \%ret; | ||
} | ||
|
||
my $res; | ||
my $n=0; | ||
for my $file (@ARGV) { | ||
my $r = loadFile($file); | ||
if ($res) { | ||
$res = combine($res,$r); | ||
} else { | ||
$res = $r; | ||
} | ||
$n++; | ||
} | ||
|
||
for my $addr (sort { $res->{$b} <=> $res->{$a} } (keys %{$res})) { | ||
if ($addr =~ /\A(\d+)\.(\d+)\.(\d+)\.(\d+):8333/) { | ||
my $a = $1*0x1000000 + $2*0x10000 + $3*0x100 + $4; | ||
printf "0x%08x %s %g%%\n",$a,$addr,(1-((1-$res->{$addr}) ** (1/$n)))*100; | ||
} | ||
} |
Oops, something went wrong.