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
package/script/genkey.ps1
CHANGED
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
|
|
2
|
-
function read-or-default {
|
|
3
|
-
Param
|
|
4
|
-
(
|
|
5
|
-
[Parameter(Mandatory=$true, Position=0)]
|
|
6
|
-
[string] $text,
|
|
7
|
-
[Parameter(Mandatory=$true, Position=1)]
|
|
8
|
-
[string] $default
|
|
9
|
-
)
|
|
10
|
-
$a = Read-Host "$text [$default]"
|
|
11
|
-
if ($a.Length -eq 0) {
|
|
12
|
-
$a = $default
|
|
13
|
-
}
|
|
14
|
-
$a
|
|
15
|
-
}
|
|
16
|
-
Function Test-CommandExists {
|
|
17
|
-
Param ($command)
|
|
18
|
-
$oldPreference = $ErrorActionPreference
|
|
19
|
-
$ErrorActionPreference = ‘stop’
|
|
20
|
-
try {
|
|
21
|
-
if (Get-Command $command) {
|
|
22
|
-
1
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
Catch {
|
|
26
|
-
0
|
|
27
|
-
}
|
|
28
|
-
Finally {
|
|
29
|
-
$ErrorActionPreference = $oldPreference
|
|
30
|
-
}
|
|
31
|
-
} #end function test-CommandExists
|
|
32
|
-
|
|
33
|
-
if (-Not (Test-CommandExists "openssl")) {
|
|
34
|
-
Write-Output "openssl does not appear to be in path."
|
|
35
|
-
exit -1
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function New-Folder {
|
|
39
|
-
param (
|
|
40
|
-
[Parameter(Mandatory=$true, Position=0)]
|
|
41
|
-
[string] $name
|
|
42
|
-
)
|
|
43
|
-
if (-Not (Test-Path -PathType Container $Name)) {
|
|
44
|
-
New-Item -Type Directory -p $Name
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
$ROOTPATH = read-or-default "rootpath" "."
|
|
49
|
-
|
|
50
|
-
$PATH_CA = "$ROOTPATH/certs/ca"
|
|
51
|
-
$PATH_SERVER = "$ROOTPATH/certs/server"
|
|
52
|
-
$PATH_CLIENT = "$ROOTPATH/certs/client"
|
|
53
|
-
$PATH_TMP = "$ROOTPATH/certs/tmp"
|
|
54
|
-
|
|
55
|
-
New-Folder($PATH_CA)
|
|
56
|
-
New-Folder($PATH_SERVER)
|
|
57
|
-
New-Folder($PATH_CLIENT)
|
|
58
|
-
New-Folder($PATH_TMP)
|
|
59
|
-
|
|
60
|
-
Write-Output ""
|
|
61
|
-
Write-Output " _____ _ __ _____ _ _ "
|
|
62
|
-
Write-Output " / ___| | |/ _| / ___(_) | | "
|
|
63
|
-
Write-Output " \ \`--. ___| | |_ ______\ \`--. _ __ _ _ __ ___ __| | "
|
|
64
|
-
Write-Output " \`--. \/ _ \ | _|______|\`--. \ |/ _\` | '_ \ / _ \/ _\` | "
|
|
65
|
-
Write-Output " /\__/ / __/ | | /\__/ / | (_| | | | | __/ (_| | "
|
|
66
|
-
Write-Output " \____/ \___|_|_| \____/|_|\__, |_| |_|\___|\__,_| "
|
|
67
|
-
Write-Output " __/ | "
|
|
68
|
-
Write-Output " |___/ "
|
|
69
|
-
Write-Output " _____ _ _____ _ "
|
|
70
|
-
Write-Output " / __ \ | | | __ \ | | "
|
|
71
|
-
Write-Output " | / \/ ___ _ __| |_ ___ | | \/ ___ _ __ ___ _ __ __ _| |_ ___ _ __ "
|
|
72
|
-
Write-Output " | | / _ \ '__| __/ __| | | __ / _ \ '_ \ / _ \ '__/ _\` | __/ _ \| '__| "
|
|
73
|
-
Write-Output " | \__/\ __/ | | |_\__ \ | |_\ \ __/ | | | __/ | | (_| | || (_) | | "
|
|
74
|
-
Write-Output " \____/\___|_| \__|___/ \____/\___|_| |_|\___|_| \__,_|\__\___/|_| "
|
|
75
|
-
Write-Output " "
|
|
76
|
-
Write-Output ""
|
|
77
|
-
|
|
78
|
-
Write-Output ""
|
|
79
|
-
Write-Output " Global conf "
|
|
80
|
-
Write-Output ""
|
|
81
|
-
|
|
82
|
-
$RSABITS = read-or-default "RSA bit length" "4096"
|
|
83
|
-
$EXPIREDAYS = read-or-default "Expire days" "365"
|
|
84
|
-
|
|
85
|
-
$PASSWORD = "."
|
|
86
|
-
while ($PASSWORD.Length -lt 4) {
|
|
87
|
-
$PASSWORD = read-or-default "Password for certs" "jspurefix"
|
|
88
|
-
if ($PASSWORD.Length -lt 4) {
|
|
89
|
-
Write-Output "Password length cannot be lower than 4 chars"
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
Write-Output ""
|
|
94
|
-
Write-Output " OpenSSL conf "
|
|
95
|
-
Write-Output ""
|
|
96
|
-
|
|
97
|
-
# Classic openssl prompt
|
|
98
|
-
|
|
99
|
-
$GK_C = read-or-default "(C) Country Name (2 letter code)" "US"
|
|
100
|
-
$GK_ST = read-or-default "(ST) State or Province Name (full name)" "."
|
|
101
|
-
$GK_L = read-or-default "(L) Locality Name (eg, city)" "city"
|
|
102
|
-
$GK_O = read-or-default "(O) Organization Name (eg, company)" "ACME Signing Authority Inc"
|
|
103
|
-
$GK_OU = read-or-default "(OU) Organizational Unit Name (eg, section) " "."
|
|
104
|
-
$GK_CN = read-or-default "(CN) Common Name (eg, your name or your server's hostname) " "localhost"
|
|
105
|
-
|
|
106
|
-
$GK_emailAddress = Read-Host "(emailAddress) Email Address []:"
|
|
107
|
-
if ($GK_emailAddress.Length -gt 0) {
|
|
108
|
-
$GK_emailAddress = "/emailAddress=$GK_emailAddress"
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
Write-Output "Please enter the following 'extra' attributes"
|
|
112
|
-
Write-Output "to be sent with your certificate request"
|
|
113
|
-
$GK_unstructuredName = Read-Host "(unstructuredName) An optional company name []:"
|
|
114
|
-
if ($GK_unstructuredName.Length -gt 0) {
|
|
115
|
-
$GK_unstructuredName = "/unstructuredName=$GK_unstructuredName"
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
$OTHER_FIELDS = ""
|
|
119
|
-
$ADD_OTHER_FIELD = "Y"
|
|
120
|
-
while ($ADD_OTHER_FIELD -eq "y" || $ADD_OTHER_FIELD -eq "Y") {
|
|
121
|
-
$ADD_OTHER_FIELD = read-or-default "Add other field [y/N]" "N"
|
|
122
|
-
if ($ADD_OTHER_FIELD -eq "y" || $ADD_OTHER_FIELD -eq "Y") {
|
|
123
|
-
$OTHER_FIELD_NAME = Read-Host "Field name: "
|
|
124
|
-
$OTHER_FIELD_VALUE = Read-Host "Field value: "
|
|
125
|
-
if ($OTHER_FIELD_VALUE.Length -eq 0) {
|
|
126
|
-
OTHER_FIELD_VALUE="."
|
|
127
|
-
}
|
|
128
|
-
$OTHER_FIELDS = "$OTHER_FIELDS/$OTHER_FIELD_NAME=$OTHER_FIELD_VALUE"
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
Write-Output ""
|
|
133
|
-
Write-Output "Generate certs "
|
|
134
|
-
Write-Output ""
|
|
135
|
-
|
|
136
|
-
# CA
|
|
137
|
-
Write-Output ""
|
|
138
|
-
Write-Output "CA"
|
|
139
|
-
Write-Output ""
|
|
140
|
-
|
|
141
|
-
openssl genrsa -des3 -passout "pass:$PASSWORD" -out "$PATH_CA/ca.key" $RSABITS
|
|
142
|
-
|
|
143
|
-
# Create Authority Certificate
|
|
144
|
-
openssl req -new -x509 -days "$EXPIREDAYS" -key "$PATH_CA/ca.key" -out "$PATH_CA/ca.crt" -passin "pass:$PASSWORD" -subj "/C=$GK_C/ST=$GK_ST/L=$GK_L/O=$GK_O/OU=$GK_OU/CN=.$GK_unstructuredName$GK_emailAddress$GK_subjectAltName$OTHER_FIELDS"
|
|
145
|
-
|
|
146
|
-
# SERVER
|
|
147
|
-
Write-Output ""
|
|
148
|
-
Write-Output "Server"
|
|
149
|
-
Write-Output ""
|
|
150
|
-
|
|
151
|
-
# Generate server key
|
|
152
|
-
openssl genrsa -out "$PATH_SERVER/server.key" $RSABITS
|
|
153
|
-
|
|
154
|
-
# Generate server cert
|
|
155
|
-
openssl req -new -key "$PATH_SERVER/server.key" -out "$PATH_TMP/server.csr" -passout "pass:$PASSWORD" -subj "/C=$GK_C/ST=$GK_ST/L=$GK_L/O=$GK_O/OU=$GK_OU/CN=$GK_CN$GK_unstructuredName$GK_emailAddress$GK_subjectAltName$OTHER_FIELDS"
|
|
156
|
-
|
|
157
|
-
# Sign server cert with self-signed cert
|
|
158
|
-
openssl x509 -req -days "$EXPIREDAYS" -passin "pass:$PASSWORD" -in "$PATH_TMP/server.csr" -CA "$PATH_CA/ca.crt" -CAkey "$PATH_CA/ca.key" -set_serial 01 -out "$PATH_SERVER/server.crt"
|
|
159
|
-
|
|
160
|
-
# CLIENT
|
|
161
|
-
|
|
162
|
-
Write-Output ""
|
|
163
|
-
Write-Output "Client"
|
|
164
|
-
Write-Output ""
|
|
165
|
-
|
|
166
|
-
openssl genrsa -out "$PATH_CLIENT/client.key" $RSABITS
|
|
167
|
-
|
|
168
|
-
openssl req -new -key "$PATH_CLIENT/client.key" -out "$PATH_TMP/client.csr" -passout "pass:$PASSWORD" -subj "/C=$GK_C/ST=$GK_ST/L=$GK_L/O=$GK_O/OU=$GK_OU/CN=CLIENT$GK_unstructuredName$GK_emailAddress$GK_subjectAltName$OTHER_FIELDS"
|
|
169
|
-
|
|
170
|
-
openssl x509 -req -days 365 -passin "pass:$PASSWORD" -in "$PATH_TMP/client.csr" -CA "$PATH_CA/ca.crt" -CAkey "$PATH_CA/ca.key" -set_serial 01 -out "$PATH_CLIENT/client.crt"
|
|
171
|
-
|
|
172
|
-
# Clean tmp dir
|
|
173
|
-
|
|
174
|
-
Remove-Item -Recurse $PATH_TMP
|
|
175
|
-
|
|
176
|
-
Write-Output ""
|
|
177
|
-
Write-Output "Done !"
|
|
178
|
-
|
|
179
|
-
exit 0
|
|
1
|
+
|
|
2
|
+
function read-or-default {
|
|
3
|
+
Param
|
|
4
|
+
(
|
|
5
|
+
[Parameter(Mandatory=$true, Position=0)]
|
|
6
|
+
[string] $text,
|
|
7
|
+
[Parameter(Mandatory=$true, Position=1)]
|
|
8
|
+
[string] $default
|
|
9
|
+
)
|
|
10
|
+
$a = Read-Host "$text [$default]"
|
|
11
|
+
if ($a.Length -eq 0) {
|
|
12
|
+
$a = $default
|
|
13
|
+
}
|
|
14
|
+
$a
|
|
15
|
+
}
|
|
16
|
+
Function Test-CommandExists {
|
|
17
|
+
Param ($command)
|
|
18
|
+
$oldPreference = $ErrorActionPreference
|
|
19
|
+
$ErrorActionPreference = ‘stop’
|
|
20
|
+
try {
|
|
21
|
+
if (Get-Command $command) {
|
|
22
|
+
1
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
Catch {
|
|
26
|
+
0
|
|
27
|
+
}
|
|
28
|
+
Finally {
|
|
29
|
+
$ErrorActionPreference = $oldPreference
|
|
30
|
+
}
|
|
31
|
+
} #end function test-CommandExists
|
|
32
|
+
|
|
33
|
+
if (-Not (Test-CommandExists "openssl")) {
|
|
34
|
+
Write-Output "openssl does not appear to be in path."
|
|
35
|
+
exit -1
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function New-Folder {
|
|
39
|
+
param (
|
|
40
|
+
[Parameter(Mandatory=$true, Position=0)]
|
|
41
|
+
[string] $name
|
|
42
|
+
)
|
|
43
|
+
if (-Not (Test-Path -PathType Container $Name)) {
|
|
44
|
+
New-Item -Type Directory -p $Name
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
$ROOTPATH = read-or-default "rootpath" "."
|
|
49
|
+
|
|
50
|
+
$PATH_CA = "$ROOTPATH/certs/ca"
|
|
51
|
+
$PATH_SERVER = "$ROOTPATH/certs/server"
|
|
52
|
+
$PATH_CLIENT = "$ROOTPATH/certs/client"
|
|
53
|
+
$PATH_TMP = "$ROOTPATH/certs/tmp"
|
|
54
|
+
|
|
55
|
+
New-Folder($PATH_CA)
|
|
56
|
+
New-Folder($PATH_SERVER)
|
|
57
|
+
New-Folder($PATH_CLIENT)
|
|
58
|
+
New-Folder($PATH_TMP)
|
|
59
|
+
|
|
60
|
+
Write-Output ""
|
|
61
|
+
Write-Output " _____ _ __ _____ _ _ "
|
|
62
|
+
Write-Output " / ___| | |/ _| / ___(_) | | "
|
|
63
|
+
Write-Output " \ \`--. ___| | |_ ______\ \`--. _ __ _ _ __ ___ __| | "
|
|
64
|
+
Write-Output " \`--. \/ _ \ | _|______|\`--. \ |/ _\` | '_ \ / _ \/ _\` | "
|
|
65
|
+
Write-Output " /\__/ / __/ | | /\__/ / | (_| | | | | __/ (_| | "
|
|
66
|
+
Write-Output " \____/ \___|_|_| \____/|_|\__, |_| |_|\___|\__,_| "
|
|
67
|
+
Write-Output " __/ | "
|
|
68
|
+
Write-Output " |___/ "
|
|
69
|
+
Write-Output " _____ _ _____ _ "
|
|
70
|
+
Write-Output " / __ \ | | | __ \ | | "
|
|
71
|
+
Write-Output " | / \/ ___ _ __| |_ ___ | | \/ ___ _ __ ___ _ __ __ _| |_ ___ _ __ "
|
|
72
|
+
Write-Output " | | / _ \ '__| __/ __| | | __ / _ \ '_ \ / _ \ '__/ _\` | __/ _ \| '__| "
|
|
73
|
+
Write-Output " | \__/\ __/ | | |_\__ \ | |_\ \ __/ | | | __/ | | (_| | || (_) | | "
|
|
74
|
+
Write-Output " \____/\___|_| \__|___/ \____/\___|_| |_|\___|_| \__,_|\__\___/|_| "
|
|
75
|
+
Write-Output " "
|
|
76
|
+
Write-Output ""
|
|
77
|
+
|
|
78
|
+
Write-Output ""
|
|
79
|
+
Write-Output " Global conf "
|
|
80
|
+
Write-Output ""
|
|
81
|
+
|
|
82
|
+
$RSABITS = read-or-default "RSA bit length" "4096"
|
|
83
|
+
$EXPIREDAYS = read-or-default "Expire days" "365"
|
|
84
|
+
|
|
85
|
+
$PASSWORD = "."
|
|
86
|
+
while ($PASSWORD.Length -lt 4) {
|
|
87
|
+
$PASSWORD = read-or-default "Password for certs" "jspurefix"
|
|
88
|
+
if ($PASSWORD.Length -lt 4) {
|
|
89
|
+
Write-Output "Password length cannot be lower than 4 chars"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Write-Output ""
|
|
94
|
+
Write-Output " OpenSSL conf "
|
|
95
|
+
Write-Output ""
|
|
96
|
+
|
|
97
|
+
# Classic openssl prompt
|
|
98
|
+
|
|
99
|
+
$GK_C = read-or-default "(C) Country Name (2 letter code)" "US"
|
|
100
|
+
$GK_ST = read-or-default "(ST) State or Province Name (full name)" "."
|
|
101
|
+
$GK_L = read-or-default "(L) Locality Name (eg, city)" "city"
|
|
102
|
+
$GK_O = read-or-default "(O) Organization Name (eg, company)" "ACME Signing Authority Inc"
|
|
103
|
+
$GK_OU = read-or-default "(OU) Organizational Unit Name (eg, section) " "."
|
|
104
|
+
$GK_CN = read-or-default "(CN) Common Name (eg, your name or your server's hostname) " "localhost"
|
|
105
|
+
|
|
106
|
+
$GK_emailAddress = Read-Host "(emailAddress) Email Address []:"
|
|
107
|
+
if ($GK_emailAddress.Length -gt 0) {
|
|
108
|
+
$GK_emailAddress = "/emailAddress=$GK_emailAddress"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
Write-Output "Please enter the following 'extra' attributes"
|
|
112
|
+
Write-Output "to be sent with your certificate request"
|
|
113
|
+
$GK_unstructuredName = Read-Host "(unstructuredName) An optional company name []:"
|
|
114
|
+
if ($GK_unstructuredName.Length -gt 0) {
|
|
115
|
+
$GK_unstructuredName = "/unstructuredName=$GK_unstructuredName"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
$OTHER_FIELDS = ""
|
|
119
|
+
$ADD_OTHER_FIELD = "Y"
|
|
120
|
+
while ($ADD_OTHER_FIELD -eq "y" || $ADD_OTHER_FIELD -eq "Y") {
|
|
121
|
+
$ADD_OTHER_FIELD = read-or-default "Add other field [y/N]" "N"
|
|
122
|
+
if ($ADD_OTHER_FIELD -eq "y" || $ADD_OTHER_FIELD -eq "Y") {
|
|
123
|
+
$OTHER_FIELD_NAME = Read-Host "Field name: "
|
|
124
|
+
$OTHER_FIELD_VALUE = Read-Host "Field value: "
|
|
125
|
+
if ($OTHER_FIELD_VALUE.Length -eq 0) {
|
|
126
|
+
OTHER_FIELD_VALUE="."
|
|
127
|
+
}
|
|
128
|
+
$OTHER_FIELDS = "$OTHER_FIELDS/$OTHER_FIELD_NAME=$OTHER_FIELD_VALUE"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
Write-Output ""
|
|
133
|
+
Write-Output "Generate certs "
|
|
134
|
+
Write-Output ""
|
|
135
|
+
|
|
136
|
+
# CA
|
|
137
|
+
Write-Output ""
|
|
138
|
+
Write-Output "CA"
|
|
139
|
+
Write-Output ""
|
|
140
|
+
|
|
141
|
+
openssl genrsa -des3 -passout "pass:$PASSWORD" -out "$PATH_CA/ca.key" $RSABITS
|
|
142
|
+
|
|
143
|
+
# Create Authority Certificate
|
|
144
|
+
openssl req -new -x509 -days "$EXPIREDAYS" -key "$PATH_CA/ca.key" -out "$PATH_CA/ca.crt" -passin "pass:$PASSWORD" -subj "/C=$GK_C/ST=$GK_ST/L=$GK_L/O=$GK_O/OU=$GK_OU/CN=.$GK_unstructuredName$GK_emailAddress$GK_subjectAltName$OTHER_FIELDS"
|
|
145
|
+
|
|
146
|
+
# SERVER
|
|
147
|
+
Write-Output ""
|
|
148
|
+
Write-Output "Server"
|
|
149
|
+
Write-Output ""
|
|
150
|
+
|
|
151
|
+
# Generate server key
|
|
152
|
+
openssl genrsa -out "$PATH_SERVER/server.key" $RSABITS
|
|
153
|
+
|
|
154
|
+
# Generate server cert
|
|
155
|
+
openssl req -new -key "$PATH_SERVER/server.key" -out "$PATH_TMP/server.csr" -passout "pass:$PASSWORD" -subj "/C=$GK_C/ST=$GK_ST/L=$GK_L/O=$GK_O/OU=$GK_OU/CN=$GK_CN$GK_unstructuredName$GK_emailAddress$GK_subjectAltName$OTHER_FIELDS"
|
|
156
|
+
|
|
157
|
+
# Sign server cert with self-signed cert
|
|
158
|
+
openssl x509 -req -days "$EXPIREDAYS" -passin "pass:$PASSWORD" -in "$PATH_TMP/server.csr" -CA "$PATH_CA/ca.crt" -CAkey "$PATH_CA/ca.key" -set_serial 01 -out "$PATH_SERVER/server.crt"
|
|
159
|
+
|
|
160
|
+
# CLIENT
|
|
161
|
+
|
|
162
|
+
Write-Output ""
|
|
163
|
+
Write-Output "Client"
|
|
164
|
+
Write-Output ""
|
|
165
|
+
|
|
166
|
+
openssl genrsa -out "$PATH_CLIENT/client.key" $RSABITS
|
|
167
|
+
|
|
168
|
+
openssl req -new -key "$PATH_CLIENT/client.key" -out "$PATH_TMP/client.csr" -passout "pass:$PASSWORD" -subj "/C=$GK_C/ST=$GK_ST/L=$GK_L/O=$GK_O/OU=$GK_OU/CN=CLIENT$GK_unstructuredName$GK_emailAddress$GK_subjectAltName$OTHER_FIELDS"
|
|
169
|
+
|
|
170
|
+
openssl x509 -req -days 365 -passin "pass:$PASSWORD" -in "$PATH_TMP/client.csr" -CA "$PATH_CA/ca.crt" -CAkey "$PATH_CA/ca.key" -set_serial 01 -out "$PATH_CLIENT/client.crt"
|
|
171
|
+
|
|
172
|
+
# Clean tmp dir
|
|
173
|
+
|
|
174
|
+
Remove-Item -Recurse $PATH_TMP
|
|
175
|
+
|
|
176
|
+
Write-Output ""
|
|
177
|
+
Write-Output "Done !"
|
|
178
|
+
|
|
179
|
+
exit 0
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ILooseObject } from '../../collections/collection'
|
|
2
|
-
import { ContainedGroupField, ContainedSimpleField,
|
|
3
|
-
|
|
2
|
+
import { ContainedGroupField, ContainedSimpleField,
|
|
3
|
+
ContainedFieldSet, ContainedField,
|
|
4
|
+
ContainedComponentField, SimpleFieldDefinition,
|
|
4
5
|
FixDefinitions, dispatchFields } from '../../dictionary'
|
|
5
6
|
import { MsgEncoder } from '../msg-encoder'
|
|
6
7
|
import { ElasticBuffer } from '../elastic-buffer'
|
|
@@ -14,6 +15,7 @@ export class AsciiEncoder extends MsgEncoder {
|
|
|
14
15
|
public bodyLengthPos: number
|
|
15
16
|
public msgTypePos: number
|
|
16
17
|
public tags: Tags
|
|
18
|
+
public checkGroups: boolean = true
|
|
17
19
|
|
|
18
20
|
constructor (public readonly buffer: ElasticBuffer,
|
|
19
21
|
public readonly definitions: FixDefinitions,
|
|
@@ -39,29 +41,6 @@ export class AsciiEncoder extends MsgEncoder {
|
|
|
39
41
|
return b
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
private static checkGroupInstanceHasDelimiter (gf: ContainedGroupField, instance: ILooseObject): boolean {
|
|
43
|
-
const delimiterField: ContainedSimpleField = gf.definition.firstSimple
|
|
44
|
-
if (!delimiterField) {
|
|
45
|
-
throw new Error(`group definition has delimiter field ${delimiterField.definition.name}`)
|
|
46
|
-
}
|
|
47
|
-
// may have a group represented by a component where first simple field is further down.
|
|
48
|
-
while (instance != null) {
|
|
49
|
-
if (instance[delimiterField.definition.name] != null) {
|
|
50
|
-
return true
|
|
51
|
-
}
|
|
52
|
-
const first = gf.definition.fields[0]
|
|
53
|
-
switch (first.type) {
|
|
54
|
-
case ContainedFieldType.Component: {
|
|
55
|
-
const cf: ContainedComponentField = first as ContainedComponentField
|
|
56
|
-
instance = instance[cf.definition.name]
|
|
57
|
-
break
|
|
58
|
-
}
|
|
59
|
-
default:
|
|
60
|
-
instance = null
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
44
|
// only reset tags after entire message is encoded - <hdr>body<trl>
|
|
66
45
|
|
|
67
46
|
public reset (): void {
|
|
@@ -70,19 +49,29 @@ export class AsciiEncoder extends MsgEncoder {
|
|
|
70
49
|
}
|
|
71
50
|
|
|
72
51
|
public encodeSet (objectToEncode: ILooseObject, set: ContainedFieldSet): void {
|
|
52
|
+
const summary: AsciiEncodeSetSummary = new AsciiEncodeSetSummary()
|
|
53
|
+
this.encodeObject(objectToEncode, set, summary)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private encodeObject (objectToEncode: ILooseObject, set: ContainedFieldSet, state: AsciiEncodeSetSummary): void {
|
|
73
57
|
const fields: ContainedField[] = this.getFields(set, objectToEncode)
|
|
74
58
|
dispatchFields(fields, {
|
|
75
59
|
simple: (sf: ContainedSimpleField) => {
|
|
76
60
|
const val: any = objectToEncode[sf.name]
|
|
77
61
|
// Empty strings are omitted as they result in empty values for tags, which are considered malformed.
|
|
78
62
|
if (val != null && val !== '') {
|
|
63
|
+
if (state.count === 0) {
|
|
64
|
+
state.firstSimple = sf
|
|
65
|
+
}
|
|
66
|
+
state.lastSimple = sf
|
|
67
|
+
state.count++
|
|
79
68
|
this.encodeSimple(objectToEncode, set, sf, val)
|
|
80
69
|
}
|
|
81
70
|
},
|
|
82
71
|
component: (cf: ContainedComponentField) => {
|
|
83
72
|
const instance: ILooseObject = objectToEncode[cf.definition.name]
|
|
84
73
|
if (instance) {
|
|
85
|
-
this.
|
|
74
|
+
this.encodeObject(instance, cf.definition, state)
|
|
86
75
|
}
|
|
87
76
|
},
|
|
88
77
|
group: (gf: ContainedGroupField) => {
|
|
@@ -108,24 +97,29 @@ export class AsciiEncoder extends MsgEncoder {
|
|
|
108
97
|
private encodeInstances (o: ILooseObject, gf: ContainedGroupField): void {
|
|
109
98
|
const noOfField: SimpleFieldDefinition = gf.definition.noOfField
|
|
110
99
|
const instances: ILooseObject[] = o[gf.name] || o[noOfField.name]
|
|
100
|
+
|
|
111
101
|
const buffer = this.buffer
|
|
112
102
|
if (!Array.isArray(instances)) {
|
|
113
103
|
throw new Error(`expected array instance for group ${noOfField.name}`)
|
|
114
104
|
}
|
|
115
105
|
if (instances) {
|
|
106
|
+
const validator = new GroupValidator(gf)
|
|
107
|
+
const test: AsciiEncodeSetSummary = validator.test
|
|
108
|
+
|
|
116
109
|
// a repeated group has number of instances at the start of group
|
|
117
110
|
this.WriteTagEquals(noOfField.tag)
|
|
118
111
|
const posValBegin = buffer.getPos()
|
|
119
112
|
buffer.writeWholeNumber(instances.length)
|
|
120
113
|
this.writeDelimiter(posValBegin, noOfField.tag)
|
|
121
|
-
instances.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
114
|
+
for (let field = 0; field < instances.length; ++field) {
|
|
115
|
+
const instance: ILooseObject = instances[field]
|
|
116
|
+
test.reset()
|
|
117
|
+
const summary = validator.getSummary(field)
|
|
118
|
+
this.encodeObject(instance, gf.definition, summary)
|
|
119
|
+
if (this.checkGroups) {
|
|
120
|
+
validator.assertInstanceValid(field)
|
|
127
121
|
}
|
|
128
|
-
}
|
|
122
|
+
}
|
|
129
123
|
}
|
|
130
124
|
}
|
|
131
125
|
|
|
@@ -258,3 +252,47 @@ export class AsciiEncoder extends MsgEncoder {
|
|
|
258
252
|
}
|
|
259
253
|
}
|
|
260
254
|
}
|
|
255
|
+
|
|
256
|
+
class GroupValidator {
|
|
257
|
+
constructor (public readonly gf: ContainedGroupField,
|
|
258
|
+
public readonly first: AsciiEncodeSetSummary = new AsciiEncodeSetSummary(),
|
|
259
|
+
public readonly test: AsciiEncodeSetSummary = new AsciiEncodeSetSummary()) {
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
getSummary (field: number) {
|
|
263
|
+
return field === 0 ? this.first : this.test
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
assertInstanceValid (field: number): void {
|
|
267
|
+
const first = this.first
|
|
268
|
+
const test = this.test
|
|
269
|
+
if (field === 0 && first.empty()) {
|
|
270
|
+
throw new Error(`first group instance has no delimeter present ${this.gf.name}`)
|
|
271
|
+
}
|
|
272
|
+
if (field > 0 && test.empty()) {
|
|
273
|
+
throw new Error(`group instance [${field}] has no delimeter present ${this.gf.name}`)
|
|
274
|
+
}
|
|
275
|
+
if (field > 0) {
|
|
276
|
+
const firstTag = first.firstSimple.definition.tag
|
|
277
|
+
const tag = test.firstSimple.definition.tag
|
|
278
|
+
if (firstTag !== tag) {
|
|
279
|
+
throw new Error(`group instance [${field}] inconsisent delimeter ${tag} expected tag ${firstTag}`)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
class AsciiEncodeSetSummary {
|
|
286
|
+
constructor (public firstSimple: ContainedSimpleField = null,
|
|
287
|
+
public lastSimple: ContainedSimpleField = null,
|
|
288
|
+
public count: number = 0) {
|
|
289
|
+
}
|
|
290
|
+
public reset (): void {
|
|
291
|
+
this.firstSimple = null
|
|
292
|
+
this.lastSimple = null
|
|
293
|
+
this.count = 0
|
|
294
|
+
}
|
|
295
|
+
public empty (): boolean {
|
|
296
|
+
return this.firstSimple === null || this.count === 0
|
|
297
|
+
}
|
|
298
|
+
}
|
|
@@ -8,7 +8,7 @@ import { ITimeFormatter } from './itime-formatter'
|
|
|
8
8
|
import { TimeFormatter } from './time-formatter'
|
|
9
9
|
import { TagPos } from '../tag-pos'
|
|
10
10
|
import { MsgTag } from '../../types'
|
|
11
|
-
import { FixMsgStoreRecord } from '../../store'
|
|
11
|
+
import { FixMsgStoreRecord, IFixMsgStoreRecord } from '../../store'
|
|
12
12
|
|
|
13
13
|
export class AsciiView extends MsgView {
|
|
14
14
|
private readonly timeFormatter: ITimeFormatter = new TimeFormatter(this.buffer)
|
|
@@ -35,7 +35,7 @@ export class AsciiView extends MsgView {
|
|
|
35
35
|
return new AsciiView(segment, buffer, null, this.ptr, delimiter, writeDelimiter)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
public toMsgStoreRecord () {
|
|
38
|
+
public toMsgStoreRecord (): IFixMsgStoreRecord {
|
|
39
39
|
return new FixMsgStoreRecord(this.getString(MsgTag.MsgType), this.getTyped(MsgTag.SendingTime), this.getTyped(MsgTag.MsgSeqNum), this.toObject())
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -23,13 +23,13 @@ export class TimeFormatter implements ITimeFormatter {
|
|
|
23
23
|
public writeUtcTimestamp (v: Date): void {
|
|
24
24
|
this.writeUtcDate(v)
|
|
25
25
|
this.buffer.writeChar(AsciiChars.Hyphen)
|
|
26
|
-
this.writeUtcTime(v
|
|
26
|
+
this.writeUtcTime(v)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
public writeLocalTimestamp (v: Date): void {
|
|
30
30
|
this.writeLocalDate(v)
|
|
31
31
|
this.buffer.writeChar(AsciiChars.Hyphen)
|
|
32
|
-
this.writeLocalTime(v
|
|
32
|
+
this.writeLocalTime(v)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
public writeUtcTime (v: Date): void {
|
|
@@ -7,7 +7,7 @@ export class EncodeProxy {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
private static SimpleFieldCheck (field: ContainedSimpleField, val: any): void {
|
|
10
|
-
const sf: ContainedSimpleField = field
|
|
10
|
+
const sf: ContainedSimpleField = field
|
|
11
11
|
const definition: SimpleFieldDefinition = sf.definition
|
|
12
12
|
if (definition.isEnum()) {
|
|
13
13
|
const resolved: boolean = definition.containsEnum(val)
|
|
@@ -73,7 +73,7 @@ export class EncodeProxy {
|
|
|
73
73
|
if (!isComplex) {
|
|
74
74
|
throw new Error(`type ${field.name} is a component but is given type "${typeof val}"`)
|
|
75
75
|
}
|
|
76
|
-
const cf: ContainedComponentField = field
|
|
76
|
+
const cf: ContainedComponentField = field
|
|
77
77
|
return EncodeProxy.checkProperties(new Proxy({}, EncodeProxy.handler(cf.definition)), val)
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -5,6 +5,7 @@ import { SegmentDescription } from '../segment-description'
|
|
|
5
5
|
import { TagType } from '../tags'
|
|
6
6
|
import { AsciiChars } from '../ascii-chars'
|
|
7
7
|
import * as moment from 'moment'
|
|
8
|
+
import { IFixMsgStoreRecord } from '../../store'
|
|
8
9
|
|
|
9
10
|
export class FixmlView extends MsgView {
|
|
10
11
|
|
|
@@ -108,4 +109,8 @@ export class FixmlView extends MsgView {
|
|
|
108
109
|
}
|
|
109
110
|
return this.stringAtPosition(position)
|
|
110
111
|
}
|
|
112
|
+
|
|
113
|
+
public toMsgStoreRecord (): IFixMsgStoreRecord {
|
|
114
|
+
return null
|
|
115
|
+
}
|
|
111
116
|
}
|
package/src/buffer/msg-view.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Tags } from './tags'
|
|
|
6
6
|
import { ContainedGroupField, ContainedComponentField, ContainedField, ContainedFieldSet, ContainedSimpleField, SimpleFieldDefinition, GroupFieldDefinition, ITypeDispatcher, reduceSet, ContainedSetType } from '../dictionary'
|
|
7
7
|
import { ILooseObject } from '../collections/collection'
|
|
8
8
|
import { ElasticBuffer } from './elastic-buffer'
|
|
9
|
+
import { IFixMsgStoreRecord } from '../store'
|
|
9
10
|
|
|
10
11
|
export abstract class MsgView {
|
|
11
12
|
protected sortedTagPosForwards: TagPos[]
|
|
@@ -414,4 +415,6 @@ export abstract class MsgView {
|
|
|
414
415
|
|
|
415
416
|
return buffer.toString()
|
|
416
417
|
}
|
|
418
|
+
|
|
419
|
+
abstract toMsgStoreRecord (): IFixMsgStoreRecord
|
|
417
420
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { MsgView } from '../../../buffer'
|
|
2
2
|
import { AsciiSession } from '../../../transport'
|
|
3
3
|
import { IJsFixLogger, IJsFixConfig } from '../../../config'
|
|
4
|
+
import { ILooseObject } from '../../../collections/collection'
|
|
4
5
|
|
|
5
6
|
export class SkeletonSession extends AsciiSession {
|
|
6
7
|
private readonly logger: IJsFixLogger
|
|
7
8
|
private readonly fixLog: IJsFixLogger
|
|
9
|
+
|
|
8
10
|
constructor (public readonly config: IJsFixConfig,
|
|
9
|
-
public readonly logoutSeconds: number = 45
|
|
11
|
+
public readonly logoutSeconds: number = 45,
|
|
12
|
+
public useInMemoryStore: boolean = false) {
|
|
10
13
|
super(config)
|
|
11
14
|
this.logReceivedMsgs = true
|
|
12
15
|
this.fixLog = config.logFactory.plain(`jsfix.${config.description.application.name}.txt`)
|
|
@@ -15,14 +18,33 @@ export class SkeletonSession extends AsciiSession {
|
|
|
15
18
|
|
|
16
19
|
protected onApplicationMsg (msgType: string, view: MsgView): void {
|
|
17
20
|
// dispatch messages
|
|
21
|
+
if (this.useInMemoryStore) {
|
|
22
|
+
const rec = view.toMsgStoreRecord()
|
|
23
|
+
this.store.put(rec).then(r => {
|
|
24
|
+
this.logger.info(`store state ${JSON.stringify(r, null, 4)}`)
|
|
25
|
+
this.dispatch(msgType, view)
|
|
26
|
+
}).catch(e => {
|
|
27
|
+
this.logger.error(e)
|
|
28
|
+
})
|
|
29
|
+
} else {
|
|
30
|
+
this.dispatch(msgType, view)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private dispatch (msgType: string, view: MsgView) {
|
|
35
|
+
const o = view.toObject()
|
|
18
36
|
switch (msgType) {
|
|
19
37
|
default: {
|
|
20
|
-
this.logger.info(`received message type ${msgType}`)
|
|
38
|
+
this.logger.info(`received message type ${msgType} ${JSON.stringify(o, null, 4)}`)
|
|
21
39
|
break
|
|
22
40
|
}
|
|
23
41
|
}
|
|
24
42
|
}
|
|
25
43
|
|
|
44
|
+
public sendMessage (msgType: string, obj: ILooseObject): void {
|
|
45
|
+
this.send(msgType, obj)
|
|
46
|
+
}
|
|
47
|
+
|
|
26
48
|
// use msgType for example to persist only trade capture messages to database
|
|
27
49
|
protected onDecoded (msgType: string, txt: string): void {
|
|
28
50
|
this.fixLog.info(txt)
|