2023-04-15 22:40:09 +00:00
|
|
|
/// <reference types="node" />
|
|
|
|
import Proxy, { ProxyOptions } from "../proxy.js";
|
|
|
|
import type { TcpSocketConnectOpts } from "net";
|
2023-04-16 02:38:07 +00:00
|
|
|
import { DataSocketOptions, PeerOptions } from "../peer.js";
|
2023-04-15 22:40:09 +00:00
|
|
|
import { PeerEntity } from "./multiSocket/types.js";
|
2023-04-16 02:38:07 +00:00
|
|
|
import Peer from "./multiSocket/peer.js";
|
2023-04-15 22:40:09 +00:00
|
|
|
export interface MultiSocketProxyOptions extends ProxyOptions {
|
|
|
|
socketClass?: any;
|
|
|
|
server: boolean;
|
|
|
|
allowedPorts?: number[];
|
|
|
|
}
|
|
|
|
export default class MultiSocketProxy extends Proxy {
|
2023-04-16 07:42:14 +00:00
|
|
|
handlePeer({ peer, muxer, ...options }: DataSocketOptions & PeerOptions): Promise<void>;
|
2023-04-15 22:40:09 +00:00
|
|
|
private socketClass;
|
|
|
|
private _peers;
|
|
|
|
private _nextPeer;
|
|
|
|
private _server;
|
|
|
|
private _allowedPorts;
|
|
|
|
constructor(options: MultiSocketProxyOptions);
|
|
|
|
private _socketMap;
|
|
|
|
get socketMap(): Map<number, number>;
|
|
|
|
private _sockets;
|
|
|
|
get sockets(): Map<number, any>;
|
2023-04-16 07:06:53 +00:00
|
|
|
handleNewPeerChannel(peer: Peer): void;
|
2023-04-15 22:40:09 +00:00
|
|
|
handleClosePeer(peer: Peer): Promise<void>;
|
|
|
|
get(pubkey: Uint8Array): PeerEntity | undefined;
|
|
|
|
update(pubkey: Uint8Array, data: Partial<PeerEntity>): void;
|
|
|
|
createSocket(options: TcpSocketConnectOpts): Promise<typeof this.socketClass>;
|
|
|
|
private _registerOpenSocketMessage;
|
|
|
|
private _registerWriteSocketMessage;
|
|
|
|
private _registerCloseSocketMessage;
|
|
|
|
private _registerTimeoutSocketMessage;
|
|
|
|
private _registerErrorSocketMessage;
|
|
|
|
private _toString;
|
|
|
|
}
|