import { Channel, Member, ServerToServerClient, User, generateUID, timestamp } from "unrealircd-s2s-client"; let sid = "999"; let client = new ServerToServerClient({ port: 6900, host: "hel1.fi.crxb.cc", hostname: "test.dev.crxb.cc", authMethod: "spkifp", sid: sid, keyPath: "./key.pem", certPath: "./cert.pem", tlsOptions: { rejectUnauthorized: false }, }); client.onRaw = (raw) => { console.log(`[${new Date().toISOString()}] ${raw}`); }; let clones: User[] = []; new Promise((resolve) => { client.onRegistered = () => { resolve(); return true; }; }).then(() => { client.onSync = () => { for (let i = 0; i < 10000; i++) { let user: User = { nickname: `user${i}${generateUID(sid) + generateUID(sid)}`, hopcount: 0, timestamp: timestamp(), username: `user${i}`, hostname: "test.dev.crxb.cc", virtualhost: "test.dev.crxb.cc", cloakedhost: "test.dev.crxb.cc", uid: generateUID(sid), usermodes: "ipqrtzBDS", gecos: "Test User", servicestamp: "0", ip: btoa("\x00\x00\x00\x00"), memberships: {}, local: true }; clones.push(user); } let channels: Channel[] = []; for (let i = 0; i < 10; i++) { let channel: Channel = { name: `#test/channel${i}`, timestamp: timestamp(), modes: "nt", bans: [], excepts: [], inviteExcepts: [], users: {}, }; channels.push(channel); } clones.forEach((user) => { client.registerUser(user); }); for (let channel of channels) { let clonedClones = [...clones]; while (clonedClones.length > 0) { let sjoinclones = clonedClones.splice(0, 8); let memberships: Member[] = []; for (let clone of sjoinclones) { memberships.push({ uid: clone.uid, prefix: "", }); } client.sjoinToChannel(channel, ...memberships); } } client.endOfSync(); client.writeRaw("PING :test.dev.crxb.cc"); }; }); client.connect();