MCPcopy Index your code
hub / github.com/cameri/nostream / isCompleteTorReply

Method isCompleteTorReply

src/tor/client.ts:49–96  ·  view source on GitHub ↗
(buffer: string)

Source from the content-addressed store, hash-verified

47 }
48
49 private isCompleteTorReply(buffer: string): boolean {
50 if (!buffer.endsWith('\r\n')) {
51 return false
52 }
53
54 const lines = buffer.split('\r\n')
55 if (lines[lines.length - 1] === '') {
56 lines.pop()
57 }
58
59 if (lines.length === 0) {
60 return false
61 }
62
63 const firstLine = lines[0].match(/^(\d{3})([\s\-+])/)
64 if (!firstLine) {
65 return false
66 }
67
68 const statusCode = firstLine[1]
69 let inDataBlock = false
70
71 for (let i = 0; i < lines.length; i++) {
72 const line = lines[i]
73
74 if (inDataBlock) {
75 if (line === '.') {
76 inDataBlock = false
77 }
78 continue
79 }
80
81 const match = line.match(/^(\d{3})([\s\-+])/)
82 if (!match || match[1] !== statusCode) {
83 return false
84 }
85
86 if (match[2] === ' ') {
87 return i === lines.length - 1
88 }
89
90 if (match[2] === '+') {
91 inDataBlock = true
92 }
93 }
94
95 return false
96 }
97
98 private sendCommand(command: string): Promise<string> {
99 return new Promise((resolve, reject) => {

Callers 2

onDataMethod · 0.95
client.spec.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected