[Plugin] Socket Plugin(v0.2b)

Započeo berroni.pwn, Oktobar 04, 2016, 11:22:24 PRE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Ime plugina: Socket Plugin
Da li ste vi napravili plugin: Ne
Ime kreatora: BlueG
Opis(obavezno):

- Zavrsen SSL related kod.
-  bugfix
- Dodan socket_sendto()
- Popravljen socket_send_array()
- Dodan ssl_get_peer_certificate()
24/06/12: (v0.1b)
- TCP server crash popravljen
- bugfix



Ovaj plugin vam dozvoljava da pravite vise TCP ili UDP socket-.a. Svaki socket prima podatke u zasebnu temu, sto znaci da se server nece zalediti. Jednom kada unistite socket, tema ce se ugasiti. Kako bi bilo veceg interesa dodad ce se i support za SSL sockete.


Plugin se moze za svasta iskoristiti, pr. :
-IRC echo bot
- novi RCON alat sa chat-om(baziran na TCP server socket-u, poput recimo GUIRCON)
- Prima SA-MP server podatke preko UDP-a.
-Komunikacija sa PHP skriptom da salje/prim podatke


PAWN SKRIPTNJE(socket.inc):
native Socket:socket_create(pType:TCP); // udp & tcp
native socket_bind(Socket:id, ip[]); // udp & tcp
native socket_connect(Socket:id, host[], port); // udp & tcp
native socket_listen(Socket:id, port); // udp & tcp
native socket_stop_listen(Socket:id); // udp & tcp
native socket_destroy(Socket:id); // udp & tcp
native socket_send(Socket:id, data[], len); // udp & tcp
native socket_sendto(Socket:id, const ip[], port, data[], len); // udp only
native socket_send_array(Socket:id, data[], size=sizeof(data)); // udp & tcp
native is_socket_valid(Socket:id); // udp & tcp
native socket_set_max_connections(Socket:id, max_remote_clients); // tcp only
native socket_close_remote_client(Socket:id, remote_clientid); // tcp only
native socket_sendto_remote_client(Socket:id, remote_clientid, data[]); // tcp only
native socket_remote_client_connected(Socket:id, remote_clientid); // tcp only
native get_remote_client_ip(Socket:id, remote_clientid, ip[]); // tcp only

// ssl stuff (requires OpenSSL)

native ssl_init(); // initialize the ssl library
native ssl_create_context(Socket:id, method);
native ssl_connect(Socket:id); // tcp (client only)
native ssl_load_cert_into_context(Socket:id, const certificate[], const private_key[]); // certificate & private_key might be the same .pem file
native ssl_shutdown(Socket:id) = socket_destroy;
native ssl_get_peer_certificate(Socket:id, method, subject[], issuer[], remote_clientid = 0xFFFF);
native ssl_set_accept_timeout(Socket:id, interval); // interval in miliseconds
native ssl_set_mode(Socket:id, mode); // see above SSL_modes (enum)



Callbacks:
// client & server (udp)
forward onUDPReceiveData(Socket:id, data[], data_len, remote_client_ip[], remote_client_port);
// client only (tcp)
forward onSocketAnswer(Socket:id, data[], data_len); // called when socket_connect() has been used and the server sends data
forward onSocketClose(Socket:id);
// server only (tcp)
forward onSocketReceiveData(Socket:id, remote_clientid, data[], data_len); // called when a remote client sends data
forward onSocketRemoteConnect(Socket:id, remote_client[], remote_clientid); // called when a remote client connects to our socket server
forward onSocketRemoteDisconnect(Socket:id, remote_clientid); // called when a remote client disconnects from our socket server


// connect to an IRC server
new Socket:sock = socket_create(TCP);
if(is_socket_valid(sock)) {
socket_connect(sock, "foco.us.irc.tl", 6667);
socket_send(sock, "NICK TestBot\r\n"); // set the nickname
socket_send(sock, "USER TestBot - - :TestBot\r\n"); // set the username & realname
socket_send(sock, "MODE TestBot +B\r\n"); // tell the server it's a bot
socket_send(sock, "JOIN #test_channel\r\n"); // join a specific channel
}

// this callback will now receive all incoming data
public onSocketAnswer(Socket:id, data[])
{
}



Download(obavezno mediafire/sendspace link):
Download(0.2a preskocen):


Windows
v0.1b http://files.g-stylezzz.com/socket_p...01b/socket.dll
v0.2b https://github.com/pBlueG/Socket/releases/tag/v0.2b (Github mirror)


Linux
v0.1b http://files.g-stylezzz.com/socket_p...v01b/socket.so
v0.2b https://github.com/pBlueG/Socket/releases/tag/v0.2b (Github mirror)


Include
v0.1b http://files.g-stylezzz.com/socket_plugin/socket.inc
v0.2b https://github.com/pBlueG/Socket/blob/master/socket.inc


Tools, Scripts
TCP server
IRC bot (TCP)
SA-MP Query protocol (UDP)
Remote Adminstration GUI (TCP)
External Chat System (TCP)
SSL server/client sample
How to communicate with a PHP script
Source:
v0.1b http://files.g-stylezzz.com/socket_p...t_v01b_src.rar
v0.2b https://github.com/pBlueG/Socket (Source browser), http://github.com/pBlueG/Socket/archive/master.zip (.zip archive)

Lepo Lepo
((Moram sto vse spamat ocu cs go xD))

L3o

*

Posluzit ce nekome u to sam siguran :D
retired