Created
September 25, 2014 08:06
-
-
Save sunng87/e9b5e6e5de67f6dc3558 to your computer and use it in GitHub Desktop.
Flash socket policy file server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
import SocketServer | |
class FlashPolicyHandler(SocketServer.StreamRequestHandler): | |
timeout = 5 | |
""" | |
The RequestHandler class for our server. | |
It is instantiated once per connection to the server, and must | |
override the handle() method to implement communication to the | |
client. | |
""" | |
def handle(self): | |
# self.request is the TCP socket connected to the client | |
self.data = self.request.recv(1024).strip() | |
if self.data == '<policy-file-request/>': | |
self.request.sendall('<cross-domain-policy><allow-access-from domain="*" to-ports="*" /></cross-domain-policy>') | |
self.request.close() | |
if __name__ == "__main__": | |
HOST, PORT = "0.0.0.0", 843 | |
SocketServer.TCPServer.allow_reuse_address = True | |
# Create the server, binding to localhost on port 9999 | |
server = SocketServer.TCPServer((HOST, PORT), FlashPolicyHandler) | |
# Activate the server; this will keep running until you | |
# interrupt the program with Ctrl-C | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment