jspurefix 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/data/session/genkey.ps1 +179 -0
- package/dist/buffer/ascii/ascii-encoder.d.ts +1 -1
- package/dist/buffer/ascii/ascii-encoder.js +42 -30
- package/dist/buffer/ascii/ascii-encoder.js.map +1 -1
- package/dist/buffer/ascii/ascii-view.d.ts +2 -2
- package/dist/buffer/ascii/ascii-view.js.map +1 -1
- package/dist/buffer/ascii/time-formatter.js.map +1 -1
- package/dist/buffer/elastic-buffer.js +1 -1
- package/dist/buffer/elastic-buffer.js.map +1 -1
- package/dist/buffer/encode-proxy.js.map +1 -1
- package/dist/buffer/fixml/fixml-encoder.js +1 -1
- package/dist/buffer/fixml/fixml-encoder.js.map +1 -1
- package/dist/buffer/fixml/fixml-view.d.ts +2 -0
- package/dist/buffer/fixml/fixml-view.js +3 -0
- package/dist/buffer/fixml/fixml-view.js.map +1 -1
- package/dist/buffer/msg-view.d.ts +2 -0
- package/dist/buffer/msg-view.js +2 -2
- package/dist/buffer/msg-view.js.map +1 -1
- package/dist/dict-parser.js +9 -9
- package/dist/dict-parser.js.map +1 -1
- package/dist/dictionary/compiler/msg-compiler.js +2 -2
- package/dist/dictionary/compiler/msg-compiler.js.map +1 -1
- package/dist/dictionary/parser/fix-repository/repository-xml-parser.js +1 -1
- package/dist/dictionary/parser/fix-repository/repository-xml-parser.js.map +1 -1
- package/dist/dictionary/parser/quickfix/quick-fix-xml-file-parser.js +1 -1
- package/dist/dictionary/parser/quickfix/quick-fix-xml-file-parser.js.map +1 -1
- package/dist/jsfix-cmd.js +3 -3
- package/dist/jsfix-cmd.js.map +1 -1
- package/dist/sample/http/oms/app.js +2 -2
- package/dist/sample/http/oms/app.js.map +1 -1
- package/dist/sample/launcher.js +2 -2
- package/dist/sample/launcher.js.map +1 -1
- package/dist/sample/tcp/qf-md/app.js +2 -2
- package/dist/sample/tcp/qf-md/app.js.map +1 -1
- package/dist/sample/tcp/recovering-skeleton/respawn-2.d.ts +2 -0
- package/dist/sample/tcp/recovering-skeleton/respawn-2.js +3 -0
- package/dist/sample/tcp/recovering-skeleton/respawn-2.js.map +1 -0
- package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js +1 -1
- package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js.map +1 -1
- package/dist/sample/tcp/skeleton/app.js +2 -2
- package/dist/sample/tcp/skeleton/app.js.map +1 -1
- package/dist/sample/tcp/skeleton/skeleton-session.d.ts +5 -1
- package/dist/sample/tcp/skeleton/skeleton-session.js +21 -2
- package/dist/sample/tcp/skeleton/skeleton-session.js.map +1 -1
- package/dist/sample/tcp/tls-trade-capture/app.js +2 -2
- package/dist/sample/tcp/tls-trade-capture/app.js.map +1 -1
- package/dist/sample/tcp/trade-capture/app.js +2 -2
- package/dist/sample/tcp/trade-capture/app.js.map +1 -1
- package/dist/sample/tcp/trade-capture/trade-capture-client.d.ts +1 -0
- package/dist/sample/tcp/trade-capture/trade-capture-client.js +7 -3
- package/dist/sample/tcp/trade-capture/trade-capture-client.js.map +1 -1
- package/dist/store/fix-msg-ascii-store-recovery.d.ts +12 -0
- package/dist/store/fix-msg-ascii-store-recovery.js +60 -0
- package/dist/store/fix-msg-ascii-store-recovery.js.map +1 -0
- package/dist/store/fix-msg-ascii-store-replay.d.ts +13 -0
- package/dist/store/fix-msg-ascii-store-replay.js +60 -0
- package/dist/store/fix-msg-ascii-store-replay.js.map +1 -0
- package/dist/store/fix-msg-ascii-store-resend.js +3 -2
- package/dist/store/fix-msg-ascii-store-resend.js.map +1 -1
- package/dist/store/fix-msg-store-record.js.map +1 -1
- package/dist/store/fix-replay-record.d.ts +12 -0
- package/dist/store/fix-replay-record.js +12 -0
- package/dist/store/fix-replay-record.js.map +1 -0
- package/dist/store/fix-resend-record.d.ts +12 -0
- package/dist/store/fix-resend-record.js +12 -0
- package/dist/store/fix-resend-record.js.map +1 -0
- package/dist/store/replay-record.d.ts +6 -0
- package/dist/store/replay-record.js +3 -0
- package/dist/store/replay-record.js.map +1 -0
- package/dist/store/store-replay-record.d.ts +12 -0
- package/dist/store/store-replay-record.js +12 -0
- package/dist/store/store-replay-record.js.map +1 -0
- package/dist/tcp/tls-options.d.ts +5 -0
- package/dist/tcp/tls-options.js +45 -0
- package/dist/tcp/tls-options.js.map +1 -0
- package/dist/test/ascii-encode.test.d.ts +1 -0
- package/dist/test/ascii-encode.test.js +416 -0
- package/dist/test/ascii-encode.test.js.map +1 -0
- package/dist/test/ascii-encoder.test.js +2 -2
- package/dist/test/ascii-encoder.test.js.map +1 -1
- package/dist/test/ascii-parser.test.js +9 -7
- package/dist/test/ascii-parser.test.js.map +1 -1
- package/dist/test/ascii-segment.test.js +7 -6
- package/dist/test/ascii-segment.test.js.map +1 -1
- package/dist/test/ascii-store-recovery.test.d.ts +1 -0
- package/dist/test/ascii-store-recovery.test.js +50 -0
- package/dist/test/ascii-store-recovery.test.js.map +1 -0
- package/dist/test/ascii-store-replay.test.js +2 -2
- package/dist/test/ascii-store-replay.test.js.map +1 -1
- package/dist/test/ascii-tag-pos.test.js +2 -2
- package/dist/test/ascii-tag-pos.test.js.map +1 -1
- package/dist/test/encode-proxy.test.js +1 -1
- package/dist/test/encode-proxy.test.js.map +1 -1
- package/dist/test/execution-report.test.js +2 -2
- package/dist/test/execution-report.test.js.map +1 -1
- package/dist/test/fix-log-replay.test.js +2 -2
- package/dist/test/fix-log-replay.test.js.map +1 -1
- package/dist/test/fix-repo-dict.test.js +1 -1
- package/dist/test/fix-repo-dict.test.js.map +1 -1
- package/dist/test/logon.test.js +2 -2
- package/dist/test/logon.test.js.map +1 -1
- package/dist/test/memory-store.test.js +2 -2
- package/dist/test/memory-store.test.js.map +1 -1
- package/dist/test/qf-full-msg.test.js +14 -13
- package/dist/test/qf-full-msg.test.js.map +1 -1
- package/dist/test/repo-full-ascii-msg.test.js +10 -9
- package/dist/test/repo-full-ascii-msg.test.js.map +1 -1
- package/dist/test/repo-full-fixml-msg.test.js +15 -15
- package/dist/test/repo-full-fixml-msg.test.js.map +1 -1
- package/dist/test/session.test.js +262 -143
- package/dist/test/session.test.js.map +1 -1
- package/dist/test/to-views.js +1 -1
- package/dist/test/to-views.js.map +1 -1
- package/dist/test/view-decode.test.js +2 -2
- package/dist/test/view-decode.test.js.map +1 -1
- package/dist/transport/ascii/ascii-msg-transmitter.js +6 -3
- package/dist/transport/ascii/ascii-msg-transmitter.js.map +1 -1
- package/dist/transport/ascii/ascii-session.d.ts +8 -0
- package/dist/transport/ascii/ascii-session.js +67 -19
- package/dist/transport/ascii/ascii-session.js.map +1 -1
- package/dist/transport/duplex/http-duplex.js +2 -2
- package/dist/transport/duplex/http-duplex.js.map +1 -1
- package/dist/transport/fix-session-state.js +4 -1
- package/dist/transport/fix-session-state.js.map +1 -1
- package/dist/transport/fix-session.d.ts +6 -0
- package/dist/transport/fix-session.js +91 -38
- package/dist/transport/fix-session.js.map +1 -1
- package/dist/transport/http/http-acceptor.js +8 -7
- package/dist/transport/http/http-acceptor.js.map +1 -1
- package/dist/transport/make-config.js +1 -1
- package/dist/transport/make-config.js.map +1 -1
- package/dist/transport/session-msg-factory.d.ts +24 -2
- package/dist/transport/session-msg-factory.js +143 -3
- package/dist/transport/session-msg-factory.js.map +1 -1
- package/dist/transport/tcp/recovering-initiator.d.ts +17 -0
- package/dist/transport/tcp/recovering-initiator.js +30 -0
- package/dist/transport/tcp/recovering-initiator.js.map +1 -0
- package/dist/transport/tcp/recovering_initiator.d.ts +12 -0
- package/dist/transport/tcp/recovering_initiator.js +25 -0
- package/dist/transport/tcp/recovering_initiator.js.map +1 -0
- package/dist/transport/tcp/resilient-initiator.d.ts +12 -0
- package/dist/transport/tcp/resilient-initiator.js +41 -0
- package/dist/transport/tcp/resilient-initiator.js.map +1 -0
- package/dist/transport/tcp/tcp-acceptor.d.ts +7 -0
- package/dist/transport/tcp/tcp-acceptor.js +57 -38
- package/dist/transport/tcp/tcp-acceptor.js.map +1 -1
- package/dist/transport/tcp/tcp-initiator.d.ts +2 -0
- package/dist/transport/tcp/tcp-initiator.js +59 -32
- package/dist/transport/tcp/tcp-initiator.js.map +1 -1
- package/dist/types/FIX4.4/quickfix/set/header.d.ts +31 -0
- package/dist/types/FIX4.4/quickfix/set/header.js +3 -0
- package/dist/types/FIX4.4/quickfix/set/header.js.map +1 -0
- package/dist/types/FIX4.4/quickfix/set/trailer.d.ts +6 -0
- package/dist/types/FIX4.4/quickfix/set/trailer.js +3 -0
- package/dist/types/FIX4.4/quickfix/set/trailer.js.map +1 -0
- package/dist/util/buffer-helper.js +1 -1
- package/dist/util/buffer-helper.js.map +1 -1
- package/dist/util/json-helper.js +2 -2
- package/dist/util/json-helper.js.map +1 -1
- package/dist/util/message-generator.js +1 -1
- package/dist/util/message-generator.js.map +1 -1
- package/package.json +16 -15
- package/script/genkey.ps1 +179 -179
- package/src/buffer/ascii/ascii-encoder.ts +71 -33
- package/src/buffer/ascii/ascii-view.ts +2 -2
- package/src/buffer/ascii/time-formatter.ts +2 -2
- package/src/buffer/encode-proxy.ts +2 -2
- package/src/buffer/fixml/fixml-view.ts +5 -0
- package/src/buffer/msg-view.ts +3 -0
- package/src/sample/tcp/skeleton/skeleton-session.ts +24 -2
- package/src/sample/tcp/trade-capture/trade-capture-client.ts +8 -3
- package/src/store/fix-msg-ascii-store-resend.ts +3 -2
- package/src/store/fix-msg-store-record.ts +1 -0
- package/src/transport/ascii/ascii-msg-transmitter.ts +6 -3
- package/src/transport/ascii/ascii-session.ts +75 -19
- package/src/transport/duplex/http-duplex.ts +2 -2
- package/src/transport/fix-session-state.ts +4 -1
- package/src/transport/fix-session.ts +98 -37
- package/src/transport/http/http-acceptor.ts +7 -6
- package/src/transport/tcp/tcp-acceptor.ts +59 -35
- package/src/transport/tcp/tcp-initiator.ts +63 -38
|
@@ -9,52 +9,76 @@ import { createServer as tlsCreateServer, TLSSocket, TlsOptions } from 'tls'
|
|
|
9
9
|
export class TcpAcceptor extends FixAcceptor {
|
|
10
10
|
private server: Server
|
|
11
11
|
private logger: IJsFixLogger
|
|
12
|
+
private nextId: number = 0
|
|
13
|
+
|
|
12
14
|
constructor (public readonly config: IJsFixConfig) {
|
|
13
15
|
super(config.description.application)
|
|
14
16
|
this.logger = config.logFactory.logger(`${config.description.application.name}:TcpAcceptor`)
|
|
15
|
-
|
|
16
|
-
const tcp = this.config.description.application.tcp
|
|
17
|
-
const tlsOptions: TlsOptions = getTlsOptions(tcp.tls)
|
|
17
|
+
const tlsOptions: TlsOptions = this.tlsOptions()
|
|
18
18
|
if (tlsOptions) {
|
|
19
|
-
|
|
20
|
-
this.logger.info(`create tls server`)
|
|
21
|
-
this.server = tlsCreateServer(tlsOptions, (tlsSocket: TLSSocket) => {
|
|
22
|
-
if (tcp.tls.enableTrace) {
|
|
23
|
-
this.logger.info(`enabling tls session trace`)
|
|
24
|
-
tlsSocket.enableTrace()
|
|
25
|
-
}
|
|
26
|
-
if (tlsSocket.authorized) {
|
|
27
|
-
tlsSocket.setEncoding('utf8')
|
|
28
|
-
const id: number = nextId++
|
|
29
|
-
this.logger.info(`tls creates session ${id} ${tlsSocket.authorized}`)
|
|
30
|
-
this.onSocket(id, tlsSocket, config)
|
|
31
|
-
} else {
|
|
32
|
-
this.logger.info(`no transport created on tls with no authorized connection`)
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
} catch (e) {
|
|
36
|
-
this.logger.error(e)
|
|
37
|
-
throw e
|
|
38
|
-
}
|
|
19
|
+
this.tlsServer()
|
|
39
20
|
} else {
|
|
40
|
-
|
|
41
|
-
this.logger.info(`create unsecured server`)
|
|
42
|
-
this.server = netCreateServer((socket: Socket) => {
|
|
43
|
-
const id: number = nextId++
|
|
44
|
-
this.logger.info(`net creates session ${id} }`)
|
|
45
|
-
socket.setNoDelay(true)
|
|
46
|
-
this.onSocket(id, socket, config)
|
|
47
|
-
})
|
|
48
|
-
} catch (e) {
|
|
49
|
-
this.logger.error(e)
|
|
50
|
-
throw e
|
|
51
|
-
}
|
|
21
|
+
this.unsecureServer()
|
|
52
22
|
}
|
|
53
23
|
this.server.on('error', ((err: Error) => {
|
|
54
24
|
throw err
|
|
55
25
|
}))
|
|
56
26
|
}
|
|
57
27
|
|
|
28
|
+
getId (): number {
|
|
29
|
+
this.nextId++
|
|
30
|
+
const id: number = this.nextId
|
|
31
|
+
return id
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
tlsServer (): void {
|
|
35
|
+
try {
|
|
36
|
+
const config: IJsFixConfig = this.config
|
|
37
|
+
const tcp = this.config.description.application.tcp
|
|
38
|
+
const tlsOptions: TlsOptions = getTlsOptions(tcp.tls)
|
|
39
|
+
this.logger.info(`create tls server`)
|
|
40
|
+
this.server = tlsCreateServer(tlsOptions, (tlsSocket: TLSSocket) => {
|
|
41
|
+
if (tcp.tls.enableTrace) {
|
|
42
|
+
this.logger.info(`enabling tls session trace`)
|
|
43
|
+
tlsSocket.enableTrace()
|
|
44
|
+
}
|
|
45
|
+
if (tlsSocket.authorized) {
|
|
46
|
+
tlsSocket.setEncoding('utf8')
|
|
47
|
+
const id: number = this.getId()
|
|
48
|
+
this.logger.info(`tls creates session ${id} ${tlsSocket.authorized}`)
|
|
49
|
+
this.onSocket(id, tlsSocket, config)
|
|
50
|
+
} else {
|
|
51
|
+
this.logger.info(`no transport created on tls with no authorized connection`)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
} catch (e) {
|
|
55
|
+
this.logger.error(e)
|
|
56
|
+
throw e
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
unsecureServer () {
|
|
61
|
+
try {
|
|
62
|
+
const config = this.config
|
|
63
|
+
this.logger.info(`create unsecured server`)
|
|
64
|
+
this.server = netCreateServer((socket: Socket) => {
|
|
65
|
+
const id: number = this.getId()
|
|
66
|
+
this.logger.info(`net creates session ${id}`)
|
|
67
|
+
socket.setNoDelay(true)
|
|
68
|
+
this.onSocket(id, socket, config)
|
|
69
|
+
})
|
|
70
|
+
} catch (e) {
|
|
71
|
+
this.logger.error(e)
|
|
72
|
+
throw e
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
tlsOptions (): TlsOptions {
|
|
77
|
+
const tcp = this.config.description.application.tcp
|
|
78
|
+
const tlsOptions: TlsOptions = getTlsOptions(tcp.tls)
|
|
79
|
+
return tlsOptions
|
|
80
|
+
}
|
|
81
|
+
|
|
58
82
|
private onSocket (id: number, socket: Socket, config: IJsFixConfig) {
|
|
59
83
|
const transport: MsgTransport = new MsgTransport(id, config, new TcpDuplex(socket))
|
|
60
84
|
this.saveTransport(id, transport)
|
|
@@ -6,9 +6,9 @@ import { IJsFixConfig, IJsFixLogger } from '../../config'
|
|
|
6
6
|
import { TcpDuplex, FixDuplex } from '../duplex'
|
|
7
7
|
|
|
8
8
|
import * as util from 'util'
|
|
9
|
-
import { connect as tlsConnect, TLSSocket } from 'tls'
|
|
9
|
+
import { connect as tlsConnect, ConnectionOptions, TLSSocket } from 'tls'
|
|
10
10
|
import { getTlsConnectionOptions } from './tls-options'
|
|
11
|
-
import {
|
|
11
|
+
import { createConnection } from 'net'
|
|
12
12
|
import Timeout = NodeJS.Timeout
|
|
13
13
|
|
|
14
14
|
export enum InitiatorState {
|
|
@@ -80,56 +80,81 @@ export class TcpInitiator extends FixInitiator {
|
|
|
80
80
|
})
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
private
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
tlsSocket.end()
|
|
96
|
-
reject(tlsSocket.authorizationError)
|
|
97
|
-
} else {
|
|
98
|
-
tlsSocket.setEncoding('utf8')
|
|
99
|
-
this.duplex = new TcpDuplex(tlsSocket)
|
|
100
|
-
resolve(new MsgTransport(0, this.jsFixConfig, this.duplex))
|
|
83
|
+
private unsecureDuplex (): Promise<TcpDuplex> {
|
|
84
|
+
const tcp = this.tcp
|
|
85
|
+
return new Promise<TcpDuplex>((resolve, reject) => {
|
|
86
|
+
try {
|
|
87
|
+
this.logger.info(`unsecureDuplex try to connect to endPoint`)
|
|
88
|
+
const socket = createConnection(tcp, () => {
|
|
89
|
+
try {
|
|
90
|
+
this.logger.info(`net.createConnection cb, resolving`)
|
|
91
|
+
const tcpDuplex = new TcpDuplex(socket)
|
|
92
|
+
resolve(tcpDuplex)
|
|
93
|
+
} catch (e) {
|
|
94
|
+
reject(e)
|
|
101
95
|
}
|
|
102
96
|
})
|
|
97
|
+
} catch (e) {
|
|
98
|
+
reject(e)
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
}
|
|
103
102
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
103
|
+
private tlsDuplex (): Promise < TcpDuplex > {
|
|
104
|
+
return new Promise<TcpDuplex>((resolve, reject) => {
|
|
105
|
+
let tlsSocket: TLSSocket = null
|
|
106
|
+
const tcp = this.tcp
|
|
107
|
+
const connectionOptions: ConnectionOptions = getTlsConnectionOptions(tcp)
|
|
108
|
+
if (connectionOptions) {
|
|
109
|
+
try {
|
|
110
|
+
tlsSocket = tlsConnect(connectionOptions, () => {
|
|
111
|
+
this.logger.info(`client connected ${tlsSocket.authorized ? 'authorized' : 'unauthorized'}`)
|
|
112
|
+
if (!tlsSocket.authorized) {
|
|
113
|
+
const error = tlsSocket.authorizationError
|
|
114
|
+
this.logger.warning(`rejecting from state ${this.state} authorizationError ${error}`)
|
|
115
|
+
tlsSocket.end()
|
|
116
|
+
reject(error)
|
|
117
|
+
} else {
|
|
118
|
+
tlsSocket.setEncoding('utf8')
|
|
119
|
+
const tlsDuplex = new TcpDuplex(tlsSocket)
|
|
120
|
+
if (tcp.tls.enableTrace) {
|
|
121
|
+
this.logger.info(`enabling tls session trace`)
|
|
122
|
+
tlsSocket.enableTrace()
|
|
123
|
+
}
|
|
124
|
+
this.logger.info(`tlsDuplex resolving`)
|
|
125
|
+
resolve(tlsDuplex)
|
|
126
|
+
}
|
|
119
127
|
})
|
|
120
|
-
})
|
|
128
|
+
} catch (e) {
|
|
129
|
+
reject(e)
|
|
130
|
+
}
|
|
121
131
|
}
|
|
122
132
|
})
|
|
123
133
|
}
|
|
124
134
|
|
|
135
|
+
private tryConnect (): Promise < MsgTransport > {
|
|
136
|
+
return new Promise<MsgTransport>((resolve, reject) => {
|
|
137
|
+
const tcp = this.tcp
|
|
138
|
+
const connectionOptions: ConnectionOptions = getTlsConnectionOptions(tcp)
|
|
139
|
+
const connector = connectionOptions ? this.tlsDuplex() : this.unsecureDuplex()
|
|
140
|
+
this.logger.info(`tryConnect ${tcp.host}:${tcp.port}`)
|
|
141
|
+
connector.then(duplex => {
|
|
142
|
+
this.duplex = duplex
|
|
143
|
+
resolve(new MsgTransport(0, this.jsFixConfig, duplex))
|
|
144
|
+
}).catch(e => {
|
|
145
|
+
reject(e)
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
125
150
|
public clearTimer () {
|
|
126
|
-
if (this.th) {
|
|
151
|
+
if (this .th) {
|
|
127
152
|
clearInterval(this.th)
|
|
128
153
|
this.th = null
|
|
129
154
|
}
|
|
130
155
|
}
|
|
131
156
|
|
|
132
|
-
private repeatConnect (timeoutSeconds: number): Promise<MsgTransport> {
|
|
157
|
+
private repeatConnect (timeoutSeconds: number): Promise < MsgTransport > {
|
|
133
158
|
return new Promise<MsgTransport>(async (resolve, reject) => {
|
|
134
159
|
const application = this.application
|
|
135
160
|
const promisify = util.promisify
|