Example #1
0
from util.sockets import ClientSocket
from util.message import Message

sock = ClientSocket('localhost', 5050)
message = Message(sock)

loginB = "l" in raw_input("(L)ogin or (R)egister?: ").lower()

domain = None
subdomain1 = None
subdomain2 = None

if loginB:
    # Do login stuff
    secret = raw_input("Enter your secret: ")
    message.send(10, 0, [secret])
    response = message.get()
    if response["code"] == 2:
        print "INVALID SECRET"
        import sys
        sys.exit(1)
    message.send(21, 1)
    response = message.get()
    domain = response["param"][0]
    subdomain1 = response["param"][1]
    subdomain2 = response["param"][2]
else:
    secret = raw_input("Enter a secret (like a password, but no security): ")
    domain = raw_input("Enter a domain: ")
    subdomain1 = raw_input("Enter a subdomain: ")
    subdomain2 = raw_input("Enter a second subdomain: ")