quick n' dirty fix for a Twisted update which broke the proxy hack
This commit is contained in:
1 parent
c4c7439ae8
commit
abb84eb055
2 files changed
+20
-12
No files matched your search
@@ -1 +1 @@
|
|||||||
<html>␍ <head>␍ <title>Info</title>␍ <meta name="uppertitle" content="Info">␍ <link rel="stylesheet" type="text/css" href="http://flipnote.hatena.com/css/ds/common.css">␍ </head>␍ <body>␍ <div class="container">␍ <div class="title" align="center">pbsds's Hatena Server</div>␍ <div class="news-body">␍ <p>This is a work in progress! There's not much functionality yet because it's still in early stages. Please enjoy your stay.</p>␍ </div>␍ </div>␍ </body>␍</html>
|
<html>␍ <head>␍ <title>Info</title>␍ <meta name="uppertitle" content="Info">␍ <link rel="stylesheet" type="text/css" href="http://flipnote.hatena.com/css/ds/common.css">␍ </head>␍ <body>␍ <div class="container">␍ <div class="title" align="center">pbsds's Hatena Server</div>␍ <div class="news-body">␍ <p>This server is a proof of concept server. There's not much functionality yet because it's in early stages. Please enjoy your stay.</p>␍ </div>␍ </div>␍ </body>␍</html>
|
||||||
@@ -113,22 +113,30 @@ print "Done!"
|
|||||||
#make the hatena server accept proxy connections:
|
#make the hatena server accept proxy connections:
|
||||||
print "Setting up proxy hack...",
|
print "Setting up proxy hack...",
|
||||||
silent = True
|
silent = True
|
||||||
old_lineReceived = site.protocol.lineReceived
|
old_buildProtocol = site.buildProtocol
|
||||||
def lineReceived(self, line):
|
def buildProtocol(self, addr):
|
||||||
if not silent: print line
|
protocol = old_buildProtocol(addr)
|
||||||
if line[:31] == "GET http://flipnote.hatena.com/":
|
|
||||||
line = "GET " + line[30:]
|
protocol.new_recv_buffer= []
|
||||||
if not silent: print line
|
|
||||||
elif line[:32] == "POST http://flipnote.hatena.com/":
|
old_dataReceived = protocol.dataReceived
|
||||||
line = "POST " + line[31:]
|
def dataReceived(self, data):
|
||||||
if not silent: print line
|
#i'll assume the GET request doesn't get fragmented, which should be safe with a mtu at 1500, a crash doesn't matter really anyway. too much work for a simple twisted upgrade on a dropped project
|
||||||
old_lineReceived(self, line)
|
for check, repl in (("GET http://flipnote.hatena.com", "GET "), ("POST http://flipnote.hatena.com", "POST ")):
|
||||||
site.protocol.lineReceived = lineReceived
|
if check in data:
|
||||||
|
data = data.replace(check, repl)
|
||||||
|
old_dataReceived(data)
|
||||||
|
funcType = type(protocol.dataReceived)
|
||||||
|
protocol.dataReceived = funcType(dataReceived, protocol, protocol.__class__)
|
||||||
|
return protocol
|
||||||
|
funcType = type(site.buildProtocol)
|
||||||
|
site.buildProtocol = funcType(buildProtocol, site, server.Site)
|
||||||
print "Done!"
|
print "Done!"
|
||||||
|
|
||||||
#run!
|
#run!
|
||||||
print "Server start!\n"
|
print "Server start!\n"
|
||||||
if useWSGI:
|
if useWSGI:
|
||||||
|
#probably doesn't work
|
||||||
application = service.Application('web')
|
application = service.Application('web')
|
||||||
sc = service.IServiceCollection(application)
|
sc = service.IServiceCollection(application)
|
||||||
internet.TCPServer(port, site).setServiceParent(sc)
|
internet.TCPServer(port, site).setServiceParent(sc)
|
||||||
|
|||||||
Reference in new issue
Block a user
