Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fqrouter committed Jun 1, 2014
1 parent c1fc8c0 commit 2975ace
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion fqsocks/proxies/http_try.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ def _try_start(self):
finally:
self.is_trying = False

def create_upstream_sock(self, client):
upstream_sock = create_scrambled_sock(client.dst_ip, client.dst_port)
upstream_sock.history = [client.src_port]
upstream_sock.counter = stat.opened(upstream_sock, client.forwarding_by, client.host, client.dst_ip)
client.add_resource(upstream_sock)
client.add_resource(upstream_sock.counter)
return upstream_sock

def before_send_request(self, client, upstream_sock, is_payload_complete):
if 'Referer' in client.headers:
del client.headers['Referer']
Expand Down Expand Up @@ -298,7 +306,20 @@ def process_response(self, client, upstream_sock, response, http_response):
def __repr__(self):
return 'TcpScrambler'


def create_scrambled_sock(ip, port):
upstream_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
if networking.OUTBOUND_IP:
upstream_sock.bind((networking.OUTBOUND_IP, 0))
upstream_sock.setsockopt(socket.SOL_SOCKET, networking.SO_MARK, 0xbabe)
upstream_sock.settimeout(3)
try:
upstream_sock.connect((ip, port))
except:
upstream_sock.close()
raise
upstream_sock.last_used_at = time.time()
upstream_sock.settimeout(None)
return upstream_sock

HTTP_TRY_PROXY = HttpTryProxy()
TCP_SCRAMBLER = TcpScrambler()
Expand Down
2 changes: 2 additions & 0 deletions fqsocks/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,14 @@ <h3>
Then you would need to use Wifi Repeater. However only a few mobile models support Wifi Repeater.
If you mobile is not one of those, starting wifi repeater might cause the system reboot.
But I can assure you, it will not do any harm to hardware.
Some device might need to Disable Wifi P2P by click config button above to make wifi repeater work.
""",
"""
系统自带的便携式热点可以共享3G,但是无法共享家庭的无线网络。
如果我在家里,显然不希望还用3G上网,但是我又想用无线把翻墙网络共享给其他设备。
这个时候你就需要使用无线中继这个功能。但是只有少数手机支持无线中继,
如果你的手机不支持可能会导致系统重启,但是肯定不会对硬件造成任何损坏。
有些设备需要通过上面的配置按钮“禁用系统的WIFI P2P”,然后无线中继才可以成功启动。
""") }}
</div>
</div>
Expand Down

0 comments on commit 2975ace

Please sign in to comment.