forked from andrchoi/CPEN443-A3-VPN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpn.py
127 lines (101 loc) · 3.16 KB
/
vpn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from tkinter import Tk, Frame, Button, Label, Entry, Checkbutton, IntVar, END, StringVar
import server
import client
def switchMode():
#TODO: implement ui switching
global inClientMode
if 'client' in modeLabel["text"]:
modeLabel.config(text = "VPN in server mode")
hostDetails.config(state='disabled')
nameOrIP.config(state='disabled')
inClientMode = False
else:
modeLabel.config(text = "VPN in client mode")
hostDetails.config(state='active')
nameOrIP.config(state='active')
inClientMode= True
print('switching', inClientMode)
def connectStep():
#TODO:
print('step')
def connectSubmit():
#TODO:
print(inClientMode)
if inClientMode:
client.connectClient(int(ss_field.get()), hostField.get(), nameIPState.get(), int(portField.get()))
else:
server.openServer(int(ss_field.get()), int(portField.get()))
print(hostField.get(), nameIPState.get(), portField.get())
def sendData():
#TODO:
if inClientMode:
print('send client')
else:
server.encryptAndSend(sendField.get())
print(sendField.get())
def nextStep():
#TODO:
print('stepping')
def executeFull():
#TODO:
print('running')
# initialize GUI area
root = Tk()
root.title('Team AMAZ VPN')
frame = Frame(root, width=500)
frame.pack()
inClientMode = True
# create Toggle button
labelText="VPN in client mode"
toggleText="Toggle mode"
modeLabel = Label(root, text=labelText)
toggle_button = Button(root, text=toggleText, command=switchMode)
modeLabel.pack()
toggle_button.pack()
# connection details
connectInfo = Label(root, text='Enter host name/IP (client only) and port number')
hostDetails = Label(root, text='Host Name/IP')
hostField = Entry(root)
nameIPState = IntVar()
nameOrIP = Checkbutton(root, text='Check if submitting IP address', variable=nameIPState)
portLabel = Label(root, text='Enter port number:')
portField = Entry(root)
connectInfo.pack()
hostDetails.pack()
hostField.pack()
nameOrIP.pack()
portLabel.pack()
portField.pack()
# shared secret field
ss_label = Label(root, text="Shared Secret Values: ")
ss_field = Entry(root)
ss_label.pack()
ss_field.pack()
# submit connection details
connectStep = Button(root, text='Step Through Connection', command=connectStep)
connectSubmit = Button(root, text='Submit Connection Details', command=connectSubmit)
connectStep.pack()
connectSubmit.pack()
# data to send
sendLabel = Label(root, text="Data to send: ")
sendField = Entry(root)
sendLabel.pack()
sendField.pack()
# received data
recLabel = Label(root, text="Received data: ")
recText = StringVar()
recData = Entry(root, textvariable=recText)
recLabel.pack()
recData.pack()
# Continue button
continueButton = Button(root, text='Step Through Send', command=nextStep)
continueButton.pack()
# Automatic Run
runButton = Button(root, text='Send Automatically', command=executeFull)
runButton.pack()
# program status
statusText = StringVar()
statusText.set('program state')
status = Label(root, textvariable=statusText)
status.pack()
root.mainloop()