Proxy Server

YSFlight general discussion & everything in between
Post Reply
User avatar
Flake
VFA-49
VFA-49
Posts: 4357
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Boeing F/A-18A
Location: Australia
OS: Windows 10 (x64)
Has thanked: 838 times
Been thanked: 1247 times
Contact:

Proxy Server

Post by Flake » Thu Dec 22, 2011 1:26 pm

Sort of a third party tool here, Want to make a proxy server so I can learn the YS Protocal, so I can thus make some decent Proxy Servers for it...

For now, I'm trying to make a very basic intercept, speak, and forward proxy... but it isn't working right.

I can send a message TO the server...

But I don't get one back.

Setup the same as YSPS. Server on 7914, Client on 7915.

Can anyone work it out? Please?

Code: Select all

import sys
import select
import socket

Server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Proxy = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#Begin Proxy
ServerAddress = ('localhost',7914)
ProxyAddress = ('localhost',7915)
#OPEN a server on 7914.
#JOIN as client on 7915.
print >>sys.stderr, 'Starting the Server on %s port %s' % ProxyAddress
print >>sys.stderr, 'Connecting the Client to %s port %s' % ServerAddress
Proxy.bind(ProxyAddress)
Server.connect(ServerAddress)

#I'm a client on 7914, a server on 7915!
Proxy.listen(1)
Client, ClientAddress = Proxy.accept()
clienttalking = True
servertalking = False

while True:
    ServerReady = select.select([Server], [], [], 0.2)
    while ServerReady[0]:
        try:
            data_server = Server.recv(4)
            #print >>sys.stderr, 'Server To Client: %s' % data_server
            Client.sendall(data_server)
            ServerReady = select.select([Server], [], [], 0.2)
        finally:
            pass
    ClientReady = select.select([Client], [], [], 0.2)
    while ClientReady[0]:
        try:
            data_client = Client.recv(4)
            #print >>sys.stderr, 'Client To Server: %s' % data_client
            Server.sendall(data_client)
            ClientReady = select.select([Client], [], [], 0.2)
        finally:
            pass
try:
    Server.close
    Client.close
    Proxy.close
finally:
    pass
EDIT: Finally fixed it, little to no lag noticable. No intercept or control features yet, however. The issue was that the sockets time out after sending a completed messeage, by using a select mainframe, I can see if the sockets are empty or not. Expect some development on this now.
I am an accountant working full-time (and some). I'm not here as often as I would like to be. Send a message if you need me. There are a few people in the community who can get in contact with me urgently if you need - don't be afraid to ask. I just don't check here as frequently as I used to. Sorry!

User avatar
vincent
Contributor
Contributor
Posts: 202
Joined: Wed Feb 02, 2011 7:31 pm
Favorite Aircraft: virtual ones
Location: Toulouse, France
Has thanked: 1 time
Been thanked: 25 times
Contact:

Re: Proxy Server

Post by vincent » Sat Dec 24, 2011 2:26 pm

I should write somewhere the specifications I know from the YS protocol.

User avatar
Flake
VFA-49
VFA-49
Posts: 4357
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Boeing F/A-18A
Location: Australia
OS: Windows 10 (x64)
Has thanked: 838 times
Been thanked: 1247 times
Contact:

Re: Proxy Server

Post by Flake » Sat Dec 24, 2011 10:20 pm

YSRadar is very VERY helpful too.
I am an accountant working full-time (and some). I'm not here as often as I would like to be. Send a message if you need me. There are a few people in the community who can get in contact with me urgently if you need - don't be afraid to ask. I just don't check here as frequently as I used to. Sorry!

User avatar
vincent
Contributor
Contributor
Posts: 202
Joined: Wed Feb 02, 2011 7:31 pm
Favorite Aircraft: virtual ones
Location: Toulouse, France
Has thanked: 1 time
Been thanked: 25 times
Contact:

Re: Proxy Server

Post by vincent » Sat Dec 24, 2011 11:46 pm

You mean the python script of the YSRadar server or the Perl version ?

User avatar
Flake
VFA-49
VFA-49
Posts: 4357
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Boeing F/A-18A
Location: Australia
OS: Windows 10 (x64)
Has thanked: 838 times
Been thanked: 1247 times
Contact:

Re: Proxy Server

Post by Flake » Sun Dec 25, 2011 4:34 am

The python script, inside it is the command codes for a few functions, mostly just the log in sequence as well as grabbing the YSF Version.

I want to know how to set day/night, wind, visibility, and most importantly... HOW TO SEND TEXT! :0

Once I'm able to intercept text, things should be good.
I am an accountant working full-time (and some). I'm not here as often as I would like to be. Send a message if you need me. There are a few people in the community who can get in contact with me urgently if you need - don't be afraid to ask. I just don't check here as frequently as I used to. Sorry!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests