twistd一行服务器的方法,搭建DNS、Web文件服务器

来源:互联网 发布:联合利华二级销售 知乎 编辑:程序博客网 时间:2024/05/23 19:16
More twistd Examples
twistdships with many commands that make it easy to spin up simple services with zero
lines of code. Here are some examples:
twistd web --port 8080 --path .
Run an HTTP server on port 8080, serving both static and dynamic content out of
the current working directory. Visit  http://localhost:8080to see the directory listing.
twistd dns -v -p 5553 --hosts-file=hosts
Run a DNS server on port 5553, resolving domains out of a file called hostsin the
format of /etc/hosts.
For example, say you’d like to run your own Twisted DNS resolver and are also
trying to cut back on social media. Create a  hostsfile that resolves  facebook.com,
twitter.com, and reddit.comto localhost, 127.0.0.1:
127.0.0.1 facebook.com
127.0.0.1 twitter.com
127.0.0.1 reddit.com
Then run your  twistdDNS resolver, configure your operating system to try that
resolver first, and effectively disable your ability to view those sites.
A quick command-line way to prove that the resolver is working is to use the dig
DNS lookup utility. First, query the default resolver, then query the twistd  resolver:
$ dig +short twitter.com
199.59.150.7
199.59.148.10
199.59.150.39
$ dig @localhost -p 5553 +short twitter.com
127.0.0.1
sudo twistd conch -p tcp:2222
Run an sshserver on port 2222. sshkeys must be set up independently.
twistd mail -E -H localhost -d localhost=emails
Run an ESMTP POP3 server, accepting email for  localhostand saving it to the  emails
directory.
I don’t know about you, but I get pretty excited by the networking power of these simple
twistdone-liners.
0 0
原创粉丝点击