Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

forced_anon chat

Name: Anonymous 2007-12-04 23:50

Imagine this: you load up a 4chan chat page, and you're connected to another user to chat one on one. Completely at random, with no traces of identity whatsoever. That's it. There could be a button to get a new person if you really don't like who you're talking to or you've seen them before, or you could just hit F5. In the true spirit of Anonymous, you could talk about anything in complete freedom.

I think that could be pretty awesome (and also pretty fail, but such is the way of all things chan), and it's an idea that I've had in the back of my mind for a while. I don't have the wherewithal to make it happen, however, so by /img/'s recommendation I'm here pitching it to /prog/ in the hope that someone will get inspired and make this happen. I'd really like to see it made real. I have to imagine that it would be very simple to make, although finding a good host and getting people to use it is another matter.

Anyone's interest piqued?

Name: Anonymous 2007-12-10 15:15

pwned

Name: Anonymous 2007-12-10 15:16

hark@rawwr> netstat -an | grep 7000 | wc -l
     267

haw haw haw

Name: Anonymous 2007-12-10 15:16

This is why we do not post IP addresses to /prog/.

Name: Anonymous 2007-12-10 15:17

This is why we can not have nice things

Name: Anonymous 2007-12-10 15:18

Yeah, the machine is still closing connections. I'm not using a kernel which supports large amounts of connections, so it basically shat itself. I'll restart the app once the port opens (since I'm too lazy to open another one on the router).

THANKS FOR PROVING ME WRONG :D

Name: Anonymous 2007-12-10 15:18

>>118
Microsoft Telnet> o rawwr.kicks-ass.net 7000
Connecting To rawwr.kicks-ass.net...Could not open connection to the host, on port 7000: Connect failed
Microsoft Telnet>

Name: Anonymous 2007-12-10 15:18

Hm, I suppose the machine ran out of memory due to Erlang, or something... it should be up by now if it was just being DDoSed.

Name: Anonymous 2007-12-10 15:19

>>125
Also, post source.

Name: >>125 2007-12-10 15:21

Okay, there's 11 connections which are in FIN_WAIT_2, and I doubt they'll be closed before they timeout, which'll probably take awhile. So in the meanwhile -

telnet://rawwr.kicks-ass.net:7001/

To be sure, this vunerability is due to a software flaw, and not a bug with the platform it's running on (Erlang).

Name: Anonymous 2007-12-10 15:22

>>127
It was just a bunch of

echo `perl -e 'print rand 0, 9999'` | netcat rawwr.kicks-ass.net 7000 &

in a while loop. I killed it a few seconds later :)

Name: Anonymous 2007-12-10 15:24

Piece of shit source for that pile of trash.

-module( server ).
-export( [ start/1, responder/1, listen/2, client/2, client_get_name/2 ] ).

start( Port )
    ->
    % Start up the responder so messages can get sent to it.
    PID_Responder = spawn( server, responder, [ [] ] ),
   
    % Make sure shit works
    PID_Responder ! { print_message, "Responder created!~n" },
   
    % Create the server socket and start the server
    case gen_tcp:listen( Port, [ list, { active, false }, { packet, line } ] ) of
        { ok, ServSock }
            ->
            { ok, Port } = inet:port( ServSock ),
            io:format( "Listening on port ~w.~n", [ Port ] ),
            listen( ServSock, PID_Responder );
        { error, Reason }
            ->
            { error, Reason }
    end.
   
listen( ServerSock, PID_Responder )
    ->
    % Grab the client attempting to connect
    case gen_tcp:accept( ServerSock ) of
        { ok, ClientSock }
            ->
            io:format( "Client connected!~n", [] ),
           
            % Send message to responder
            PID_Responder ! { new_client, ClientSock },
           
            % Continue listening.
            listen( ServerSock, PID_Responder );
           
        Other
            ->
            io:format( "gen_tcp:accept returned ~p. Quitting.~n", [ Other ] )
    end
    .
   
client( { ClientSock, ClientName }, PID_Responder )
    ->   
    % Just wait for something to happen.
    case gen_tcp:recv( ClientSock, 0 ) of
        { ok, RawMsg }    
            ->
            Msg = io_lib:format( "~s", [ RawMsg ] ),
            io:format( "~s sent message: ~s", [ ClientName, Msg ] ),
            PID_Responder ! {
                client_message,
                io_lib:format(
                    "<~s> ~s",
                    [ ClientName, Msg ]
                )
            },
            client( { ClientSock, ClientName }, PID_Responder );
        { error, closed }
            ->
            io:format( "~s disconnected.", [ ClientName ] ),
            PID_Responder ! { client_closed, { ClientSock, ClientName } }
    end
    .

client_get_name( ClientSock, PID_Responder )
    ->
    % Send the request.
    gen_tcp:send( ClientSock, "Enter username: " ),
   
    % Get it back.
    case gen_tcp:recv( ClientSock, 0 ) of
        { ok, ClientName }
            ->
            { _, StrippedClientName1, _ } =
                regexp:sub(
                    ClientName,
                    "^[ \t\r\n]*",
                    ""
                ),
           
            { _, StrippedClientName, _ } =
                regexp:sub(
                    StrippedClientName1,
                    "[ \t\r\n]*$",
                    ""
                ),
           
            PID_Responder ! { client_choose_name, { ClientSock, StrippedClientName } };
        { error, _ }
            ->
            io:format( "Unable to get client name.~n", [] ),
            io:format( "Client disconnected.~n", [] )
    end
    .

% This could be better implemented with a high-order fun + lists:foreach
send_to_all_clients( [ { ClientSock, _ } | Rest ], Msg )
    ->
    gen_tcp:send( ClientSock, Msg ),
    send_to_all_clients( Rest, Msg );
   
send_to_all_clients( [], _ )
    ->
    ok
    .

responder( ClientList )
    ->
    % Message handler
    receive
        { print_message, Message }
            ->
            % Just print the message...
            io:format( Message, [] ),
           
            % Loop
            responder( ClientList );
       
        { new_client, ClientSock }
            ->
            % Spawn a new thread for this client, attempt to get name
            spawn( server, client_get_name, [ ClientSock, self() ] ),
       
            % Loop
            responder( ClientList );
       
        { client_choose_name, { ClientSock, ClientName } }
            ->
            % Make sure the name isn't taken.
            case lists:keysearch( ClientName, 2, ClientList ) of
                false
                    ->
                    % Add the client into the list
                    NewClientList = [ { ClientSock, ClientName } | ClientList ],
           
                    % Send the join message to all users
                    send_to_all_clients(
                        NewClientList,
                        io_lib:format(
                            "~s has joined the chat.~n",
                            [ ClientName ]
                        )
                    ),
                   
                    % Set up the thread to listen for that client
                    spawn( server, client,
                        [ { ClientSock, ClientName }, self() ]
                    ),
                   
                    % Loop with new client list.
                    responder( NewClientList );
                   
                { value, _ }
                    ->
                    % Send them a message
                    gen_tcp:send( ClientSock,
                        io_lib:format(
                            "The name ~s is already taken.~n",
                            [ ClientName ]
                        )
                    ),
                   
                    % Request they choose another name
                    spawn( server, client_get_name, [ ClientSock, self() ] ),
           
                    % Loop with old client list.
                    responder( ClientList )
            end;
           
            % Already looped above.
       
        { client_message, Msg }
            ->
            % Message is preformatted.
           
            % Need to send the message to all clients.
            send_to_all_clients( ClientList, Msg ),
       
            % Loop
            responder( ClientList );
       
        { client_closed, { ClientSock, ClientName } }
            ->
            % Remove the entry from the list, if it exists.
            NewClientList = lists:keydelete( ClientSock, 1, ClientList ),
           
            % Send message to all clients about logoff.
            send_to_all_clients(
                NewClientList,
                io_lib:format( "~s has left the chat.~n", [ ClientName ] )
            ),
       
            % loop
            responder( NewClientList )
    end
    .

Name: Anonymous 2007-12-10 15:32

>>130
echo `perl -e 'print rand 0, 9999'`

Well, aren't you a fucking expert.

Name: Anonymous 2007-12-10 15:38

Someone killed the server :(

Name: Anonymous 2007-12-10 15:38

Haha, looks like it broke again :D

Name: Anonymous 2007-12-10 15:38

pawned?

Name: Anonymous 2007-12-10 15:39

>>132
try it without

Name: Anonymous 2007-12-10 15:40

I should like, save the output logs from Erlang so I can figure out where it's crashing, lulz.

Name: Anonymous 2007-12-10 15:41

port 7003 soon?

Name: Anonymous 2007-12-10 15:41

Okay, it's back on port 7000 again. Going to have to wait for a bunch of half-open TCP connections to close on 7001.

Name: Anonymous 2007-12-10 15:47

The problem is this was meant to be 1-on-1 chat, when I connected it seemed like a bunch of people were just spamming stuff.

Name: Anonymous 2007-12-10 15:54

>>140
Welcome to /prog/. I'm too lazy to implement matchmaking features, really. Maybe if I have some freetime later I'll sit down and do it, lol.

Also, lol @ whoever is echo'ing the thing to itself. Awesome.

Name: Anonymous 2007-12-10 16:02

Okay, I'm turning it off for now. Source is posted for anyone else who wants to run it. The spam is (amazingly) eating too much bandwidth and I don't have any traffic shaping. I had fun though, thanks for the laughs, /prog/

Name: Anonymous 2007-12-10 16:24

This thread was brought to you by EXPERT PROGRAMMING(tm)

Name: Anonymous 2007-12-10 17:14

>>142
Ah, and so life imitates art.

Name: Anonymous 2007-12-10 19:34

This is a winning thread

Name: Anonymous 2007-12-10 23:16

... Holy fuck. Well I'm glad someone gave this a shot, although I was hoping ultimately for some kind of web-based interface, as the telnet prompt isn't exactly user friendly. On that note, I can probably do a quick crash course in AJAX and cobble together some sort of front end if whoever writes the back end can give me a few pointers.

Name: Anonymous 2007-12-10 23:41

>>146
DO NOT WANT

Name: Anonymous 2007-12-10 23:58

>>146
Telnet is more user friendly than Fire"omnomnommemory"fox.

Name: 131 2007-12-11 1:37

New server: telnet://213.10.200.234:20656/
Does one-to-one chat, heavily modified version of >>131.

-module( server ).
-export( [ start/1, responder/1, listen/5, client/2,
    client_listen/2, client_mainloop/4 ] ).

start( Port )
    ->
    % Start up the responder so messages can get sent to it.
    PID_Responder = spawn( server, responder, [ [] ] ),

    % Create the server socket and start the server
    case gen_tcp:listen( Port, [ list, { active, false }, { packet, line } ] ) of
        { ok, ServSock }
            ->
            { ok, Port } = inet:port( ServSock ),
            io:format( "Listening on port ~w.~n", [ Port ] ),
            listen( ServSock, PID_Responder, invalid, 0, [] );
        { error, Reason }
            ->
            { error, Reason }
    end
    .

listen( ServerSock, PID_Responder, LastIP, IPtimes, BannedIPs )
    ->
    % Grab the client attempting to connect
    case gen_tcp:accept( ServerSock, 5 * 60 * 1000 ) of
        { ok, ClientSock }
            ->
            % IP checking and banning
            { ok, { IP, _ } } = inet:peername( ClientSock ),
            io:format( "Client connected from ~p!~n", [ IP ] ),
            case lists:member(IP, BannedIPs) of
                true
                    ->
                    gen_tcp:send( ClientSock, "B&\n" ),
                    gen_tcp:close( ClientSock ),
                    listen( ServerSock, PID_Responder, IP, 0, BannedIPs );
                false
                    ->
                    % Set up the thread to listen for that client
                    spawn( server, client, [ClientSock, PID_Responder] ),

                    case IP == LastIP of
                        true
                            ->
                            case IPtimes < 10 of
                                true
                                    ->
                                    listen( ServerSock, PID_Responder, IP, IPtimes + 1, BannedIPs );
                                false
                                    ->
                                    listen( ServerSock, PID_Responder, IP, 0, [ IP | BannedIPs ] )
                            end
                            ;
                        false
                            ->
                            listen( ServerSock, PID_Responder, IP, 0, BannedIPs )
                    end
             end
             ;
        Other
            ->
            io:format( "gen_tcp:accept returned ~p. Quitting.~n", [ Other ] )
    end
    .

client( ClientSock, PID_Responder )
    ->
    % Welcome message
    gen_tcp:send( ClientSock,
"HAVE YOU READ YOUR SICP TODAY?

Use /next to ditch current chatpartner.
Use /echo to toggle echoing.

Waiting for a chatter...\n"),

    % Make thread to handle connection
    spawn( server, client_listen, [ ClientSock, self() ] ),

    % Add to list of available chatters
    PID_Responder ! { add_client, self() },

    % Go into the main loop
    client_mainloop( ClientSock, PID_Responder, nope, false )
    .

client_mainloop( ClientSock, PID_Responder, Otherperson, Echo )
    ->
    receive
        { toggle_echo }
            ->
            gen_tcp:send( ClientSock,
                io_lib:format("Echo mode set to ~p~n", [ not Echo ] )),

            client_mainloop( ClientSock, PID_Responder, Otherperson, not Echo );

        { die }
            ->
            case Otherperson of
                nope
                ->
                    ok;
                PID
                ->
                    PID ! { disconnected }
            end
            ,
            PID_Responder ! { remove_client, self() },

            % Loop
            client_mainloop( ClientSock, PID_Responder, nope, Echo );

        { removed }
            ->
            % We have been removed. No looping, so it exits
           ok;

        { disconnected }
            ->
            % Other party disconnected
            gen_tcp:send( ClientSock, "Disconnected...\n" ),

            % Get back in the available list
            PID_Responder ! { add_client, self() },
           
            % Loop
            client_mainloop( ClientSock, PID_Responder, nope, Echo );

        { connected, PID }
            ->
            io:format("~p connected to ~p~n", [self(), PID]),
            % We got connected
            gen_tcp:send( ClientSock, "Connected to a chatter.\n\n" ),
            % Loop
            client_mainloop( ClientSock, PID_Responder, PID, Echo );

        { disconnect }
            ->
            case Otherperson of
                nope
                    ->
                    ok;
                PID
                    ->
                    PID    ! { disconnected },
                    self() ! { disconnected }
            end
            ,

            % Loop
            client_mainloop( ClientSock, PID_Responder, Otherperson, Echo );

        { message, Message }
            ->
            gen_tcp:send( ClientSock, io_lib:format("<Anonymous> ~s~n", [ Message ] ) ),

            % Loop
            client_mainloop( ClientSock, PID_Responder, Otherperson, Echo );

        { send_message, Message }
            ->
            case Otherperson of
                nope
                    ->
                    ok;
                PID
                    ->
                    case Echo of
                        true
                            ->
                            gen_tcp:send( ClientSock,
                            io_lib:format("<Me> ~s~n", [ Message ] ) );
                        false
                            ->
                            ok
                    end
                    ,
                    PID ! { message, Message }
            end
            ,

            % Loop
            client_mainloop( ClientSock, PID_Responder, Otherperson, Echo )
    end
    .

isprintable( Character )
    ->
    Character >= 32 andalso Character =< 126
    .

client_listen( ClientSock, ClientPID )
    ->
    % Just wait for something to happen.
    case gen_tcp:recv( ClientSock, 0 ) of
        { ok, RawMsg }
            ->
            Msg = lists:filter( fun isprintable/1, RawMsg ),

            case lists:sublist(Msg, 5) of
                "/next"
                    ->
                    ClientPID ! { disconnect };

                "/echo"
                    ->
                    ClientPID ! { toggle_echo };

                _
                    ->
                    ClientPID ! { send_message, Msg }
            end
            ,

            % Loop
            client_listen( ClientSock, ClientPID );

        { error, _ }
            ->
            gen_tcp:close(ClientSock),
            ClientPID ! { die }
    end
    .

random2( Max )
    ->
    % Get two random numbers 1 <= x <= Max
    Random1 = random:uniform( Max ),
    Random2 = random:uniform( Max ),
    case Random1 == Random2 of
        true
            ->
            random2( Max );
        false
            ->
            {Random1, Random2}
    end
    .

connect_clients( AvailableList )
    ->
    io:format("Available: ~p~n", [ AvailableList ]),
    Length = length( AvailableList ),
    case Length < 2 of
        true
            ->
            AvailableList;
        false
            ->
            {Random1, Random2} = random2( Length ),
            Elem1 = lists:nth( Random1, AvailableList),
            Elem2 = lists:nth( Random2, AvailableList),
            io:format("Connecting ~p and ~p~n", [Elem1, Elem2]),
            Elem1 ! { connected, Elem2 },
            Elem2 ! { connected, Elem1 },
            connect_clients(
                lists:delete( Elem1, lists:delete( Elem2, AvailableList ) )
            )
    end
    .

responder( AvailableList )
    ->
    % Message handler
    receive
        { remove_client, ClientPID }
            ->
            io:format( "remove_client ~p~n", [ ClientPID ] ),
            % Remove the entry from the list, if it exists.
            NewAvailableList = lists:delete( ClientPID, AvailableList ),

            % Callback to try to avoid synchronization issues
            ClientPID ! {removed},

            % Loop
            responder( NewAvailableList );

        { add_client, ClientPID }
            ->
            io:format( "add_client ~p~n", [ ClientPID ] ),

            % Add the client into the list and try to connect client pairs
            NewAvailableList = connect_clients( [ ClientPID | AvailableList ] ),

            % Loop
            responder( NewAvailableList )
    end
    .

Name: Anonymous 2007-12-11 1:41

Oops, delete the 5 * 60 * 1000 part.

Name: >>131 2007-12-11 3:01

>>149
FUCK YEAH ERLANG! :D

Name: Anonymous 2007-12-11 4:16

>>89 here
Right smack in the middle of my first finals week of comp sci grad school, which is why I can't do it this week. But this weekend, I will probably hack something together. It shouldn't be too hard to pair people up, and once they're paired up, I see no reason why they'd need to go through the server anymore, so it shouldn't be _too much_ of a load on the server.

(except of course, EXPERT PROGRAMMERS may DoS it, etc...)

Name: Anonymous 2007-12-11 4:39

It's empty. Post URL in /b/ or something.

Name: Anonymous 2007-12-11 6:39

THERES ANOTHER ON BEEN POSTED ON B. WHY IS IT NOT MENTIONED HERE. I GOT BANNED FROM IT FOR STRESS TESTING.

Name: Anonymous 2007-12-11 6:51

>>152
FIREWALLS/NATS BUTT MUNCH

Name: Anonymous 2007-12-11 7:59

This fails. I have nothing to talk about.

Name: Anonymous 2007-12-11 8:02

how secure is this

Name: Anonymous 2007-12-11 8:04

>>157
Everyone sniffing your network connection can read what you're typing, and the administrator of the server logs all chats.

Name: Anonymous 2007-12-11 8:10

>>158
is that it?

Name: Anonymous 2007-12-11 8:18

>>159
What else were you expecting?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List