MCPcopy Create free account
hub / github.com/cameri/nostream / addOnion

Method addOnion

src/tor/client.ts:135–148  ·  view source on GitHub ↗
(port: number, host?: string, privateKey?: string | null)

Source from the content-addressed store, hash-verified

133 }
134
135 async addOnion(port: number, host?: string, privateKey?: string | null): Promise<OnionResult> {
136 const key = privateKey ?? 'NEW:BEST'
137 const portSpec = host !== undefined ? `${port},${host}:${port}` : `${port}`
138 const response = await this.sendCommand(`ADD_ONION ${key} Port=${portSpec}`)
139
140 const result: OnionResult = {}
141 for (const line of response.split('\r\n')) {
142 const m = line.match(/^250[-\s](\w+)=(.+)$/)
143 if (m) { (result as Record<string, string>)[m[1]] = m[2] }
144 }
145 if (result.ServiceID) { result.ServiceID += '.onion' }
146 if (!result.PrivateKey && privateKey) { result.PrivateKey = privateKey }
147 return result
148 }
149
150 async quit(): Promise<void> {
151 await this.sendCommand('QUIT').catch(() => undefined)

Callers 1

addOnionFunction · 0.80

Calls 1

sendCommandMethod · 0.95

Tested by

no test coverage detected