lionfaggot Posted February 7, 2011 Share Posted February 7, 2011 (edited) well, it works, kind of anyways.. i tested this on my ircd and, well, the proxy sends the command and all, but it KEEPS sending them over and over. (irc18)-> CAP LS (irc18)-> NICK Rolling_Guy_Number_0 (irc18)-> USER PXQGYRZAPM 0 * :PXQGYRZAPM (irc18)-> CAP LS (irc18)-> NICK Rolling_Guy_Number_0 (irc18)-> USER PXQGYRZAPM 0 * :PXQGYRZAP (irc18)-> CAP LS (irc18)-> NICK Rolling_Guy_Number_0 (irc18)-> USER PXQGYRZAPM 0 * :PXQGYRZAPM (irc18)-> CAP LS -------------^ the above is an example, it keeps sending that over and over when i connect to my irc from the proxy and here is my code: expandcollapse popup#Include <Array.au3> Global $mainarray[30000][4] $mainarray[0][0] = "client" $mainarray[0][1] = "server" $mainarray[0][2] = "request" $mainarray[0][3] = "host" TcpStartup() global $client = TcpListen(@IPAddress1, 1814) while 1 sleep(100) $current = TcpAccept($client) if $current <> -1 then For $i = 1 To UBound($mainarray) -1 $mainarray[$i][0] = $current $request = TcpRecv($mainarray[$i][0], 300000) if @error Then tcpclosesocket($mainarray[$i][0]) $mainarray[$i][0] = "" Else $mainarray[$i][2] = $request _debug($mainarray[$i][0],$request) endif Next EndIf if $current = -1 Then tcpclosesocket($current) endif _server() wend func _debug($pclient,$prequest) $treq = stringsplit($prequest, " ") if $treq[1] = "Connect" Then $cmethod = stringsplit($treq[2], ":") $psock = TcpConnect(tcpnametoip($cmethod[1]), $cmethod[2]) if $psock <> -1 Then For $i = 1 To UBound($mainarray) -1 $mainarray[$i][1] = $psock TcpSend($mainarray[$i][0], "HTTP/1.0 200 Connection established" & @CRLF) TcpSend($mainarray[$i][0], "Proxy-agent: coolproxy 1.0" & @CRLF) Next EndIf if $psock = -1 Then TcpCloseSocket($psock) TcpCloseSocket($mainarray[$i][0]) For $i = 1 To UBound($mainarray) -1 $mainarray[$i][0] = "" $mainarray[$i][2] = "" next EndIf Else _debug_s($prequest) EndIf EndFunc func _debug_s($preq) For $i = 1 To UBound($mainarray) -1 if $mainarray[$i][1] <> "" Then TCPSend($mainarray[$i][1],$preq) EndIf Next EndFunc func _server() For $i = 1 To UBound($mainarray) -1 $request = TCPrecv($mainarray[$i][1], 300000) if @error Then TcpCloseSocket($mainarray[$i][1]) TcpCloseSocket($mainarray[$i][0]) $mainarray[$i][1] = "" $mainarray[$i][0] = "" Else TcpSend($mainarray[$i][0], $request) EndIf Next EndFunc if anyone can help me fix this up it'd be awesome. thanks! Edited February 7, 2011 by lionfaggot Link to comment Share on other sites More sharing options...
jvanegmond Posted February 7, 2011 Share Posted February 7, 2011 The problem is that there is no structure anywhere. You have a function called _debug which connects to the remote webserver. I hope I don't have to tell you what is wrong with that. No one likes reading poorly written code, and everyone hates fixing poorly written code. As far as I am concerned, I know there are members who think otherwise, you don't deserve help on this one. github.com/jvanegmond Link to comment Share on other sites More sharing options...
flyingboz Posted February 7, 2011 Share Posted February 7, 2011 @Manadar,Woo, man. Even by my standards that's harsh By Valik's, you're as gentle as a feather, I guess.@OPYou've got an infinite loop heavily featured in the code you've written; it is no surprise that the loop continues infinitely.Often to debug, you can use a if foo then action 1, else action 2 construct you can determine where your logic error lies.Don't give up, better coding / formulation of posts will come with time and a willingness to learn. You spend much time here,and a certain level of frustration w/ poorly worded questions / lack of experience is a given. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
lionfaggot Posted February 7, 2011 Author Share Posted February 7, 2011 well, you know i only started a week ago. how many people can code a nearly functional proxy server within their first week. give me some credit mang Link to comment Share on other sites More sharing options...
lionfaggot Posted February 7, 2011 Author Share Posted February 7, 2011 ill eventually figure it out on my own. probably by today. shit man, the ircd im using to debug i coded myself in mirc sockets. i might be a n00b but im probably one of the more advanced n00bs :| Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now