code4craft / blackhole Goto Github PK
View Code? Open in Web Editor NEWA simple unrecursive DNS server. It can easily be configured to intercept some kind of request to one address.
A simple unrecursive DNS server. It can easily be configured to intercept some kind of request to one address.
加入设置 *.google.com ip 之后,
想对 code.google.com 单独设置其他的 ip
不知道能否支持,测试了下,好像目前还是不行
说下我们遇到的场景,我们把BlackHole服务部署到客户的网络中,现象是访问任何域名都失败,而且把所有访问域名写到blacklist中。是不是可以说明,当地DNS被劫持或污染。
14-07-23 18:04:46,395 WARN us.codecraft.blackhole.connector.UDPConnectionWorker
(UDPConnectionWorker.java:47) ## Error processing UDP connection from /192.168.5
0.20:59460,
java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Unknown Source)
at sun.nio.ch.DatagramChannelImpl.send(Unknown Source)
at us.codecraft.blackhole.forward.MultiUDPForwarder.send(MultiUDPForward
er.java:94)
at us.codecraft.blackhole.forward.MultiUDPForwarder.forward(MultiUDPForw
arder.java:79)
at us.codecraft.blackhole.forward.MultiUDPForwarder.forward(MultiUDPForw
arder.java:51)
at us.codecraft.blackhole.connector.UDPConnectionWorker.run(UDPConnectio
nWorker.java:43)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
尝试重装java也不行
我遇到的,电信和联通访问8.8.8.8都是先返回错误的数据包,再有正确的数据包跟在后面。
最近用移动的网络发现,移动的DNS污染8.8.8.8只返回错误的,不返回正确的结果。一直等待正确结果直到超时。
blackhole可以设置外部DNS,但是目前外部DNS没有办法设置优先级,对于企业内网用户来说,可能希望内部DNS优先生效,所以需要给外部DNS加上优先级功能,优先使用某个DNS的结果,并进行缓存。
之前的A记录配置,全部都转变为正则表达式并进行逐个匹配,在配置多时性能下降明显。新版本将非模糊匹配的记录直接转变为key-value类型进行强匹配,加强了性能。
初步怀疑是request=>response过程中使用DNS头部ID作为key,当此ID重复时,会返回错误的domain对应的响应体。感谢@yaniswang 的使用和反馈。
使用blackhole绑定hosts的用户存在定制的需求,目前解决方案只能是:自己在本地启动blackhole。因为很多用户IP地址会发生变化,多设备之间同步不方便,因此可以提供一个在统一的server里根据不同的用户组,响应不同结果的功能。初定按照IP进行过滤,对于同一网段,也可以考虑使用MAC地址,更加方便。
Log如下:
λ lei blackhole → λ git master → sudo ./blackhole.sh start
Starting blackhole...
λ lei blackhole → λ git master → Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'husbandEar': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private us.codecraft.wifesays.me.TCPSocketMonitor us.codecraft.wifesays.me.HusbandEar.tcpSocketMonitor; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wifesaysTcpSocketMonitor' defined in URL [jar:file:/usr/local/blackhole/blackhole.jar!/spring/applicationContext-blackhole.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [us.codecraft.wifesays.me.TCPSocketMonitor]: Constructor threw exception; nested exception is java.net.BindException: Address already in use
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at us.codecraft.blackhole.BlackHole.main(BlackHole.java:64)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private us.codecraft.wifesays.me.TCPSocketMonitor us.codecraft.wifesays.me.HusbandEar.tcpSocketMonitor; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wifesaysTcpSocketMonitor' defined in URL [jar:file:/usr/local/blackhole/blackhole.jar!/spring/applicationContext-blackhole.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [us.codecraft.wifesays.me.TCPSocketMonitor]: Constructor threw exception; nested exception is java.net.BindException: Address already in use
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
Forward的请求包不合规范,forward到114.114.114.114时,会一直没有响应。抓包看了一下,没有将UDP包按照长度截断。
因为UDP本身是无连接的,在转发模式下,可以直接将:
“用户=>blackhole=>远程DNS服务器” 和“远程DNS服务器=>blackhole=>用户”两个处理过程分开。
这样可以避免在线程中等待,将线程数大大降低。同时放弃使用wait/notify的方法进行同步,提高性能。
如题,谢谢
1.路径不能有空格,否则会报错,貌似找 zones 的时候空格后面的字符忽略了
程序路径为 D:\My Documents\GitHub\blackhole\server\bin
java.io.FileNotFoundException: D:\My\config\zones (系统找不到指定的路径。)
2.日志居然在 D:\usr\local\blackhole\cache 目录下面
我使用 msys 启动后,日志还是相同的位置
msys 下程序路径: D:\My Documents\msys\local\blackhole
cache 是不是应该放到 blackhole.jar 同级目录下呢.
最后,对这个软件赞一个!
顺便推荐一个 dns 168.95.1.1 ,速度和 8.8.8.8 差不多
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.