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

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值