Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Coding Corner
You last visited: Today at 04:13

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[NodeJS] Silkroad Security API + clientless example

Discussion on [NodeJS] Silkroad Security API + clientless example within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
gigola123's Avatar
 
elite*gold: 0
Join Date: Jun 2007
Posts: 727
Received Thanks: 459
[NodeJS] Silkroad Security API + clientless example

Hello everyone,

Just releasing my Silkroad Security API wrapper for node.js, it's not something big but you can do whatever you want with it, first of all I was rewritting all SilkroadSecurityAPI with javascript but it wasn't stable so I prefered to use the current API written in C++, biggest credits goes to Drew and WeeMan.

With this lib you can do whatever you want, I did a proxy but have to test all the performance, also a real clientless, moving share ect.. from a website. It can make your creation more extensible.

The main purpose of this system is to run the lib from an other operating system than Windows, then you can make your own proxy on a linux server which will handle all the network traffic.

You can read the readme.md or follow those step:
  • Install node.js with npm (node >= 12)
  • run: npm install silkroad-security --ignore-scripts

Then you can do whatever you want, "--ignore-scripts" in installation will skip the build stuff, if you want to use the compiled file directly.

Here an example of clientless which work:

Code:
const { SilkroadSecurityJS, stream } = require('silkroad-security'),
    net = require('net');

let silkroad = {
        ip: '127.0.0.1',
        port: 15779,
        version: 201,
        local: 22
    },
    security = new SilkroadSecurityJS(),
    client = new net.Socket()
    

client.connect({
    host: silkroad.ip,
    port: silkroad.port,
    onread: {
        buffer: Buffer.alloc(8 * 1024)
    }
});

client.on('data', (data) => {
    security.Recv(data)
});

setInterval(() => {

    let packToSend = security.GetPacketToSend()

    for (let y = 0; y < packToSend.length; y++) {
        let data = Buffer.from(packToSend[y])
        client.write(data)
    }

    let packetToRecv = security.GetPacketToRecv()

    for (let i = 0; i < packetToRecv.length; i++) {
        HandlePacketGateway(security, packetToRecv[i])
    }


}, 1)

client.on('close', () => {
	console.log('Connection closed');
});

function HandlePacketGateway(security, packet) {

    let reader = new stream.reader(packet['data'])

    console.log((packet['opcode']).toString(16))

    if (packet['opcode'] == 0x2001) {

        let server = reader.string()

		if (server == 'GatewayServer') {

            let rep = new stream.writer();
            rep.uint8(silkroad.local);
            rep.string("SR_Client");
            rep.uint32(silkroad.version);
            
            security.Send(0x6100, rep, true, false)

        } 
            
    } else if (packet['opcode'] == 0xA100) {

        security.Send(0x6101, [], true, false)

    } else if (packet['opcode'] == 0xA101) {

        while (reader.uint8() == 1) {
            reader.uint8();
            reader.string('ascii');
        }

        var servers = []

        while (reader.uint8() == 1) {
            
            var server = {
                serverID: reader.uint16(),
                Name: reader.string('ascii'),
                ratio : reader.float(),
                status: reader.uint8()
            };

            server.players = Math.round(server.ratio * 3500.0);
            servers.push(server);
        }

        console.log('--- Servers ---')
        console.log(servers);

    }

}
With a bit more code, you can make it login into game world, move ect..

I also tested it for make proxy between modules, it worked well, if you want to change the identity, there is 2 way:

Code:
let ssjs = new SilkroadSecurityJS("SR_Client", 0)
Or
Code:
let ssjs = new SilkroadSecurityJS()
ssjs.ChangeIdentity("SR_Client", 0)
By default it'll use the SR_Client identity

Here the npm link ->
gigola123 is offline  
Thanks
7 Users
Old 03/30/2020, 01:34   #2
 
JellyBitz's Avatar
 
elite*gold: 0
Join Date: Sep 2018
Posts: 427
Received Thanks: 962
Quote:
Originally Posted by gigola123 View Post
... I did a proxy but have to test all the performance ...
What about connection stability?
It is like connecting a socket and keep it alive as much as I want?
Probabilities to be constantly disconnected?
What do you think about the most servers using HWID which means client it's required?
JellyBitz is offline  
Old 03/30/2020, 03:04   #3
 
gigola123's Avatar
 
elite*gold: 0
Join Date: Jun 2007
Posts: 727
Received Thanks: 459
Quote:
Originally Posted by JellyBitz View Post
What about connection stability?
Well, actually for our customers (out of Silkroad), we built a node.js socket.io app with 2000 concurrent user with "cluster mode" in 8 process () and it works without any problem, sometimes we've some disconnect because of the user's connection but it's not really a big impact.

Quote:
Originally Posted by JellyBitz View Post
It is like connecting a socket and keep it alive as much as I want?
Probabilities to be constantly disconnected?
But yes, you can keep it alive as much as you want but I never really worked with TCP and node.js together to be honest, only on some little scale project, this is why I want to test it in a larger scale. I ran 10 clients a whole day with a little proxy, tried much exploit like the "A003 ddos", everything worked well, never crash and no process overload, everything run fine and I was on a single thread.

Quote:
Originally Posted by JellyBitz View Post
What do you think about the most servers using HWID which means client it's required?
I guess you speak about the clientless, if you can parse the packet which the HWID send then send the good one it's good I think, probably some HWID will add the current time, at this point you'll have to "uncrypt" their logic and recreat it on the clientless.

By the way, I've seen what you did with your xSroMap, it's really nice good idea to use Leaflet.
Your project xSroMap is the best think to allie with this library.
Have a clientless server which send socket.io data to your xSroMap then everything is in real time, it's an interesting project !
gigola123 is offline  
Thanks
1 User
Old 04/01/2020, 04:24   #4
 
elite*gold: 111
Join Date: May 2009
Posts: 617
Received Thanks: 589
well its good effort and good work mate but imo I'd prefer running .net or c++ app in background with json rpc instead of running nodejs for silkroad connection. I don't see the any pros of using nodejs here

btw xSroMap is really good project, we have already implemetend such feature on our server check
qoaway is offline  
Old 04/25/2020, 20:06   #5

 
Otakanikaru's Avatar
 
elite*gold: 133
Join Date: Nov 2013
Posts: 454
Received Thanks: 455
Looks like saved me some time, thanks a lot.
Otakanikaru is offline  
Thanks
1 User
Old 05/01/2020, 13:10   #6
 
elite*gold: 420
Join Date: Oct 2009
Posts: 30
Received Thanks: 5
Thank you mate
ArmOReTotTL is offline  
Reply


Similar Threads Similar Threads
[Buying] Bitskins API - NODEJS Programmierhilfe
12/09/2017 - Counter-Strike Trading - 0 Replies
Hallo, ich suche Support bzw. jemanden, der mir einen Bot für die Bitskins API in NODEJS programmieren kann. Falls jemand das nötige Know-how besitzt meldet euch bei mir.
C# Silkroad Security api . Packets
12/30/2013 - SRO Coding Corner - 14 Replies
i Added The Source Code of the Clientless Login .. if any one can Tell Me How Can i Send Packets From it !! in Silkroad Security Api DLL How Can i Send Packet Like This One
Coder für 2D Map Movement MMO NodeJS
07/18/2013 - Web Development - 1 Replies
Hallo, ich bin der Besitzer und Betreiber eines Online Pokemon Browsergames, und ich bräuchte jemanden der mir eine Art 2D Map Movement ins Spiel einbauen kann. 2D Map Movement: Registrierte Spieler können sich wie in den echten Spielen frei auf 2D Map's bewegen und andere Spieler sehen. Eine Vorlage für solch ein Map Movement wären z.B. die Open Source Spiele Pokemon Chat (github), mozilla's Browserquest (github) und rpgjs. Der Server für das Map Movement sollte mit NodeJS arbeiten...
NodeJS Arcade Game Website
09/25/2012 - Web Development - 5 Replies
Ihr alle kennt sie, Flashgame Webseiten... Die Scripts gibts überall, sie sind vollautomatisch, bringen den Betreibern Geld ein und sind vor allem eins; Web 1.0 ... Flash ist tot, und da sich jede Laberbacke das Maul aufreisst über Flash, aber niemand die Marktlücke anpackt habe ich folgende Idee. Ich habe in letzter Zeit mehrere kleine Spiele in NodeJS angefangen. Alle sind Multiplayertauglich und machen schon für kurze Zeit & länger Spass. Ich möchte nun eine dieser Flashgame Seiten...
Silkroad Security API
06/09/2011 - SRO Coding Corner - 5 Replies
i was trying to run the server_stats example but it just immediately closeed and i cant figure out why.. also i think i need ti configure the ip or port? where can i do this? edit: I've found the error.. Index was Outside the bounds of the array line 33 the code:



All times are GMT +1. The time now is 04:14.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.