Fixed HTTP

This commit is contained in:
root 2017-09-02 20:55:34 +00:00
parent febeb39adf
commit b28c6cfbf3

View file

@ -19,10 +19,11 @@ import jinja2
import paramiko
import threading
j2log = "Connection from: {{ ip }} ({{ port }}) ({{ proto }})"
#j2send = "\n\n\nYour IP Address is {{ ip }} ({{ port }})\n\n\n\n"
j2send = """{
@ -35,9 +36,6 @@ j2send = """{
}"""
class log_management:
def __init__(self):
self.logpath = "/etc/checkmyip/"
@ -184,25 +182,14 @@ def http_talker(client, valdict):
valdict.update({"proto": "http"})
log(j2format(j2log, valdict))
response_body_raw = j2format(j2send, valdict)
response_headers = {
'Content-Type': 'text/html; encoding=utf8',
'Content-Length': len(response_body_raw),
'Connection': 'close',
}
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)
response_headers_raw = """HTTP/1.1 200 OK
Content-Length: %s
Content-Type: application/json; encoding=utf8
Connection: close""" % str(len(response_body_raw))
client.send(response_headers_raw + "\n\n" + response_body_raw)
client.close()
def start():
talkers = {22: ssh_talker, 23: telnet_talker, 80: http_talker}
for talker in talkers: