-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy.py
43 lines (37 loc) · 1022 Bytes
/
proxy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import socket
from bluetooth import *
from threading import *
HOST = '' # Symbolic name meaning all available interfaces
PORT = 25000
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
try:
#s1=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#s1.connect(("mail.netfarm.it", 25))
s1=BluetoothSocket( RFCOMM )
s1.connect(("00:26:CC:70:34:13", 12))
class Server(Thread):
def run(self):
while True:
res = s1.recv(2048)
if len(res) == 0:
break
print res
conn.send(res)
Server().start()
while True:
op = conn.recv(12000)
if len(op) == 0:
break
print op
s1.send(op)
except:
print "Unexpected error:", sys.exc_info()[0]
if conn is not None:
conn.close()
s.close()
raise
s.close()