forked from BSDCafe/checkmyip
Fixed HTTP
This commit is contained in:
parent
febeb39adf
commit
b28c6cfbf3
1 changed files with 7 additions and 20 deletions
25
checkmyip.py
25
checkmyip.py
|
@ -19,6 +19,7 @@ import jinja2
|
||||||
import paramiko
|
import paramiko
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
|
||||||
j2log = "Connection from: {{ ip }} ({{ port }}) ({{ proto }})"
|
j2log = "Connection from: {{ ip }} ({{ port }}) ({{ proto }})"
|
||||||
#j2send = "\n\n\nYour IP Address is {{ ip }} ({{ port }})\n\n\n\n"
|
#j2send = "\n\n\nYour IP Address is {{ ip }} ({{ port }})\n\n\n\n"
|
||||||
|
|
||||||
|
@ -35,9 +36,6 @@ j2send = """{
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class log_management:
|
class log_management:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.logpath = "/etc/checkmyip/"
|
self.logpath = "/etc/checkmyip/"
|
||||||
|
@ -184,25 +182,14 @@ def http_talker(client, valdict):
|
||||||
valdict.update({"proto": "http"})
|
valdict.update({"proto": "http"})
|
||||||
log(j2format(j2log, valdict))
|
log(j2format(j2log, valdict))
|
||||||
response_body_raw = j2format(j2send, valdict)
|
response_body_raw = j2format(j2send, valdict)
|
||||||
response_headers = {
|
response_headers_raw = """HTTP/1.1 200 OK
|
||||||
'Content-Type': 'text/html; encoding=utf8',
|
Content-Length: %s
|
||||||
'Content-Length': len(response_body_raw),
|
Content-Type: application/json; encoding=utf8
|
||||||
'Connection': 'close',
|
Connection: close""" % str(len(response_body_raw))
|
||||||
}
|
client.send(response_headers_raw + "\n\n" + response_body_raw)
|
||||||
response_headers_raw = ''.join('%s: %s\n' % (k, v) for k, v in \
|
|
||||||
response_headers.iteritems())
|
|
||||||
response_proto = 'HTTP/1.1'
|
|
||||||
response_status = '200'
|
|
||||||
response_status_text = 'OK'
|
|
||||||
client.send('%s %s %s' % (response_proto, response_status, response_status_text))
|
|
||||||
client.send(response_headers_raw)
|
|
||||||
client.send('\n')
|
|
||||||
client.send(response_body_raw)
|
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
talkers = {22: ssh_talker, 23: telnet_talker, 80: http_talker}
|
talkers = {22: ssh_talker, 23: telnet_talker, 80: http_talker}
|
||||||
for talker in talkers:
|
for talker in talkers:
|
||||||
|
|
Loading…
Reference in a new issue