since the dotnet version of Realm.Server has a problem with certificates (see https://forums.realm.io/t/net-realm-server-notifier-startasync-never-connects-to-realm-cloud-instance-because-of-ssl-exception/1625), it was suggested by realm to use the nodejs package.
I am quite new to nodejs and so I tried to implement a change event listener using node. All that based on https://docs.realm.io/platform/using-synced-realms/server-side-usage/data-change-events#creating-event-handlers-in-node-js.
Unfortunatly I am not able to get it working.
The node process stops running when realm is trying to connect (or at least is doing something in background). Anyhow the addListener method makes it stop.
I am sorry but there is not much I could provide. I've attached my sample code and the console output of the node process.
Does anyone has any experience with it? Or any tips where I could look up for some detailed logs, etc.?
Thanks in advance!!
'use strict';
const realm = require('realm');
const http = require('http');
const name = 'node-hello-world';
const port = '8888';
const app = new http.Server();
// the URL to the Realm Object Server
const realmUrl = '//myinstance.de1a.cloud.realm.io';
const userName = 'admin';
const userPassword = 'AnyPassword';
// The regular expression you provide restricts the observed Realm files to only the subset you
// are actually interested in. This is done in a separate step to avoid the cost
// of computing the fine-grained change set if it's not necessary.
const notifierPath = '^/([^/]+)/user-data';
//declare admin user
let adminUser = undefined;
// The handleChange callback is called for every observed Realm file whenever it
// has changes. It is called with a change event which contains the path, the Realm,
// a version of the Realm from before the change, and indexes indication all objects
// which were added, deleted, or modified in this change
var handleChange = async function(changeEvent) {
// Extract the user ID from the virtual path, assuming that we're using
// a filter which only subscribes us to updates of user-scoped Realms.
var matches = changeEvent.path.match("^/([^/]+)/([^/]+)$");
var userId = matches[1];
var r = changeEvent.realm;
console.log(`Change event for ${userId}`);
};
// register the event handler callback
async function main() {
try {
realm.Sync.setLogLevel('all');
console.log("Creating instance of credentials");
var credentials = realm.Sync.Credentials.usernamePassword(userName, userPassword);
console.log("Logging in user.");
adminUser = await realm.Sync.User.login(`https:${realmUrl}`, credentials);
console.log(`Adding realm listener for path ${notifierPath}`);
//if this line was called, the console will exit in a few seconds; if not the node process will continue running
realm.Sync.addListener(`realms:${realmUrl}`, adminUser, notifierPath, 'change', handleChange);
console.log("Added listener");
} catch (exception) {
console.log("An error has occured.");
console.log(exception);
}
}
main();
app.on('request', (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('Hello World');
res.end('\n');
});
app.listen(port, () => {
console.log(`${name} is listening on port ${port}`);
});
------------------------------
Path>node app.js
Creating instance of credentials
Logging in user.
node-hello-world is listening on port 8888
Adding realm listener for path ^/([^/]+)/user-data
Global notifier: start()
Realm sync client ([realm-core-5.10.1], [realm-sync-3.10.0], protocol version 25)
Config param: max_open_files = 256
Config param: one_connection_per_session = 1
Config param: connect_timeout = 600000 ms
Config param: connection_linger_time = 30000 ms
Config param: ping_keepalive_period = 600000 ms
Config param: pong_keepalive_timeout = 600000 ms
Config param: fast_reconnect_limit = 60000 ms
Config param: enable_upload_log_compaction = 1
Config param: tcp_no_delay = 0
Added listener
Connection[1]: WebSocket::Websocket()
Connection[1]: Session[1]: Binding 'Path\realm-object-server\listener\realms.realm' to '/__admin'
Connection[1]: Session[1]: Activating
Opening Realm file: Path\realm-object-server\listener\realms.realm
Connection[1]: Session[1]: last_version_available = 0
Connection[1]: Session[1]: progress_server_version = 0
Connection[1]: Session[1]: progress_client_version = 0
Using already open Realm file: Path\realm-object-server\listener\realms.realm
Connection[1]: Session[1]: Progress handler called, downloaded = 0, downloadable = 0, uploaded = 0, uploadable = 0, progress version = 0, snapshot version = 1
Connection[1]: Resolving 'myinstance.de1a.cloud.realm.io:443'
Connection[1]: Connecting to endpoint '18.185.186.xx:443' (1/3)
Connection[1]: Connected to endpoint '18.185.186.xx:443' (from '127.0.0.1:53094')
Connection[1]: Verifying server SSL certificate using root certificates, host name = myinstance.de1a.cloud.realm.io, server port = 443, certificate =
-----BEGIN CERTIFICATE-----
MIIEdTCCA12gAwIBAgIJAKcOSkw0grd/MA0GCSqGSIb3DQEBCwUAMGgxCzAJBgNV
BAYTAlVTMSUwIwYDVQQKExxTdGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTIw
MAYDVQQLEylTdGFyZmllbGQgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0
eTAeFw0wOTA5MDIwMDAwMDBaFw0zNDA2MjgxNzM5MTZaMIGYMQswCQYDVQQGEwJV
UzEQMA4GA1UECBMHQXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTElMCMGA1UE
ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjE7MDkGA1UEAxMyU3RhcmZp
ZWxkIFNlcnZpY2VzIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IC0gRzIwggEi
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVDDrEKvlO4vW+GZdfjohTsR8/
y8+fIBNtKTrID30892t2OGPZNmCom15cAICyL1l/9of5JUOG52kbUpqQ4XHj2C0N
Tm/2yEnZtvMaVq4rtnQU68/7JuMauh2WLmo7WJSJR1b/JaCTcFOD2oR0FMNnngRo
Ot+OQFodSk7PQ5E751bWAHDLUu57fa4657wx+UX2wmDPE1kCK4DMNEffud6QZW0C
zyyRpqbn3oUYSXxmTqM6bam17jQuug0DuDPfR+uxa40l2ZvOgdFFRjKWcIfeAg5J
Q4W2bHO7ZOphQazJ1FTfhy/HIrImzJ9ZVGif/L4qL8RVHHVAYBeFAlU5i38FAgMB
AAGjgfAwge0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0O
BBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMB8GA1UdIwQYMBaAFL9ft9HO3R+G9FtV
rNzXEMIOqYjnME8GCCsGAQUFBwEBBEMwQTAcBggrBgEFBQcwAYYQaHR0cDovL28u
c3MyLnVzLzAhBggrBgEFBQcwAoYVaHR0cDovL3guc3MyLnVzL3guY2VyMCYGA1Ud
HwQfMB0wG6AZoBeGFWh0dHA6Ly9zLnNzMi51cy9yLmNybDARBgNVHSAECjAIMAYG
BFUdIAAwDQYJKoZIhvcNAQELBQADggEBACMd44pXyn3pF3lM8R5V/cxTbj5HD9/G
VfKyBDbtgB9TxF00KGu+x1X8Z+rLP3+QsjPNG1gQggL4+C/1E2DUBc7xgQjB3ad1
l08YuW3e95ORCLp+QCztweq7dp4zBncdDQh/U90bZKuCJ/Fp1U1ervShw3WnWEQt
8jxwmKy6abaVd38PMV4s/KCHOkdp8Hlf9BRUpJVeEXgSYCfOn8J3/yNTd126/+pZ
59vPr5KW7ySaNRB6nJHGDn2Z9j8Z3/VyVOEVqQdZe4O/Ui5GjLIAZHYcSNPYeehu
VsyuLAOQ1xk4meTKCRlb/weWsKh/NEnfVqn3sF/tM+2MR7cwA130A4w=
-----END CERTIFICATE-----
Connection[1]: Verifying server SSL certificate using 155 root certificates
Connection[1]: Server SSL certificate verified using root certificate(29):
-----BEGIN CERTIFICATE-----
MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UE
ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENs
YXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5
MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2ll
cywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRo
b3JpdHkwggEgMA0GCSqGSIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N
78gDGIc/oav7PKaf8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMe
j2YcOadN+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0
X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4Umkhyn
ArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W
93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRb
Vazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0fhvRbVazc1xDCDqmI56FspGowaDEL
MAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAw
BgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1ep
oXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D
eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJlxy16paq8
U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJDKVtH
CN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
QBFGmh95DmK/D5fs4C8fF5Q=
-----END CERTIFICATE-----
Connection[1]: WebSocket::initiate_client_handshake()
Connection[1]: HTTP request =
GET /realm-sync/%2F__admin HTTP/1.1
Authorization: Realm-Access-Token version=1 token="xxx"
Connection: Upgrade
Host: myinstance.de1a.cloud.realm.io
Sec-WebSocket-Key: 0TpYePZIZMhOid08TiAQzw==
Sec-WebSocket-Protocol: io.realm.sync.25
Sec-WebSocket-Version: 13
Upgrade: websocket
Connection[1]: WebSocket::handle_http_response_received()
Connection[1]: HTTP response = HTTP/1.1 101 Switching Protocols
Connection: upgrade
Date: Sun, 14 Oct 2018 11:22:13 GMT
sec-websocket-accept: A/hVVKTFOsJneK3U/SBQMisIyIg=
sec-websocket-protocol: io.realm.sync.25
Server: nginx/1.13.5
upgrade: websocket
Connection[1]: Will emit a ping in 467729 milliseconds
Connection[1]: Session[1]: Sending: BIND(path='/__admin', signed_user_token_size=601, need_client_file_ident=1)
Connection[1]: Session[1]: Received: IDENT(client_file_ident=13, client_file_ident_salt=7274062357029523918)
Using already open Realm file: Path\realm-object-server\listener\realms.realm
Connection[1]: Session[1]: Sending: IDENT(client_file_ident=13, client_file_ident_salt=7274062357029523918, scan_server_version=0, scan_client_version=0, latest_server_version=0, latest_server_version_salt=0)
Connection[1]: Session[1]: Sending: MARK(request_ident=2)
Download message compression: is_body_compressed = 1, compressed_body_size=2054, uncompressed_body_size=5474
Received: DOWNLOAD CHANGESET(server_version=1, client_version=0, origin_timestamp=119025057956, origin_file_ident=2, original_changeset_size=370, changeset_size=370)
Changeset: 3F 00 07 41 63 63 6F 75 6E 74 3F 01 0A 50 65 72 6D 69 73 73 69 6F 6E 3F 02 09 52 65 61 6C 6D 46 69 6C 65 3F 03 04 70 61 74 68 3F 04 04 55 73 65 72 3F 05 06 75 73 65 72 49 64 3F 06 0F 55 73 65 72 4D 65 74 61 64 61 74 61 52 6F 77 3F 07 08 70 72 6F 76 69 64 65 72 3F 08 0A 70 72 6F 76 69 64 65 72 49 64 3F 09 04 75 73 65 72 3F 0A 09 72 65 61 6C 6D 46 69 6C 65 3F 0B 07 6D 61 79 52 65 61 64 3F 0C 08 6D 61 79 57 72 69 74 65 3F 0D 09 6D 61 79 4D 61 6E 61 67 65 3F 0E 09 75 70 64 61 74 65 64 41 74 3F 0F 09 72 65 61 6C 6D 54 79 70 65 3F 10 09 73 79 6E 63 4C 61 62 65 6C 3F 11 05 6F 77 6E 65 72 3F 12 09 63 72 65 61 74 65 64 41 74 3F 13 07 69 73 41 64 6D 69 6E 3F 14 08 61 63 63 6F 75 6E 74 73 3F 15 08 6D 65 74 61 64 61 74 61 3F 16 03 6B 65 79 3F 17 05 76 61 6C 75 65 02 00 00 02 01 00 02 02 01 03 02 00 02 04 01 05 02 00 02 06 00 00 00 0B 07 02 00 00 0B 08 02 00 00 00 01 0B 09 0C 00 04 0B 0A 0C 00 02 0B 0B 01 00 00 0B 0C 01 00 00 0B 0D 01 00 00 0B 0E 08 00 00 00 02 0B 0F 02 00 00 0B 10 02 00 00 0B 11 0C 00 04 0B 12 08 00 00 00 04 0B 13 01 00 00 0B 14 0D 00 00 0B 15 0D 00 06 00 06 0B 16 02 00 00 0B 17 02 00 00
Received: DOWNLOAD CHANGESET(server_version=2, client_version=0, origin_timestamp=119025057963, origin_file_ident=2, original_changeset_size=208, changeset_size=208)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 05 6F 77 6E 65 72 3F 04 09 63 72 65 61 74 65 64 41 74 00 00 04 D5 88 82 E0 F4 F3 85 E4 E0 00 A4 E3 DF D7 AD A0 B3 BA 07 02 08 2F 64 65 66 61 75 6C 74 06 02 01 D5 88 82 E0 F4 F3 85 E4 E0 00 A4 E3 DF D7 AD A0 B3 BA 07 00 09 72 65 66 65 72 65 6E 63 65 06 02 02 D5 88 82 E0 F4 F3 85 E4 E0 00 A4 E3 DF D7 AD A0 B3 BA 07 00 07 64 65 66 61 75 6C 74 06 40 03 D5 88 82 E0 F4 F3 85 E4 E0 00 A4 E3 DF D7 AD A0 B3 BA 07 00 06 08 04 D5 88 82 E0 F4 F3 85 E4 E0 00 A4 E3 DF D7 AD A0 B3 BA 07 00 A1 F7 F2 DD 05 C0 ED 98 CB 03
Received: DOWNLOAD CHANGESET(server_version=3, client_version=0, origin_timestamp=119025058022, origin_file_ident=2, original_changeset_size=202, changeset_size=202)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 05 6F 77 6E 65 72 3F 04 09 63 72 65 61 74 65 64 41 74 00 00 04 C1 CF E7 BE C5 FA 94 88 07 AD E1 ED 8E 8E 83 8F D2 D0 00 02 08 2F 5F 5F 61 64 6D 69 6E 06 02 01 C1 CF E7 BE C5 FA 94 88 07 AD E1 ED 8E 8E 83 8F D2 D0 00 00 04 66 75 6C 6C 06 02 02 C1 CF E7 BE C5 FA 94 88 07 AD E1 ED 8E 8E 83 8F D2 D0 00 00 07 64 65 66 61 75 6C 74 06 40 03 C1 CF E7 BE C5 FA 94 88 07 AD E1 ED 8E 8E 83 8F D2 D0 00 00 06 08 04 C1 CF E7 BE C5 FA 94 88 07 AD E1 ED 8E 8E 83 8F D2 D0 00 00 A2 F7 F2 DD 05 80 E3 BE 0A
Received: DOWNLOAD CHANGESET(server_version=4, client_version=0, origin_timestamp=119025058024, origin_file_ident=2, original_changeset_size=201, changeset_size=201)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 05 6F 77 6E 65 72 3F 04 09 63 72 65 61 74 65 64 41 74 00 00 04 D5 C0 D0 E0 A8 C1 8C EB EE 01 9A F3 F6 F5 D9 BE D2 99 37 02 07 2F 5F 5F 70 65 72 6D 06 02 01 D5 C0 D0 E0 A8 C1 8C EB EE 01 9A F3 F6 F5 D9 BE D2 99 37 00 04 66 75 6C 6C 06 02 02 D5 C0 D0 E0 A8 C1 8C EB EE 01 9A F3 F6 F5 D9 BE D2 99 37 00 07 64 65 66 61 75 6C 74 06 40 03 D5 C0 D0 E0 A8 C1 8C EB EE 01 9A F3 F6 F5 D9 BE D2 99 37 00 06 08 04 D5 C0 D0 E0 A8 C1 8C EB EE 01 9A F3 F6 F5 D9 BE D2 99 37 00 A2 F7 F2 DD 05 80 EC B8 0B
Received: DOWNLOAD CHANGESET(server_version=5, client_version=0, origin_timestamp=119025058029, origin_file_ident=2, original_changeset_size=221, changeset_size=221)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 05 6F 77 6E 65 72 3F 04 09 63 72 65 61 74 65 64 41 74 00 00 04 B2 F8 DA D1 D7 8D 8F FF C7 01 BD EE F4 A5 FA DB D4 C2 FC 01 02 16 2F 5F 5F 77 69 6C 64 63 61 72 64 70 65 72 6D 69 73 73 69 6F 6E 73 06 02 01 B2 F8 DA D1 D7 8D 8F FF C7 01 BD EE F4 A5 FA DB D4 C2 FC 01 00 04 66 75 6C 6C 06 02 02 B2 F8 DA D1 D7 8D 8F FF C7 01 BD EE F4 A5 FA DB D4 C2 FC 01 00 07 64 65 66 61 75 6C 74 06 40 03 B2 F8 DA D1 D7 8D 8F FF C7 01 BD EE F4 A5 FA DB D4 C2 FC 01 00 06 08 04 B2 F8 DA D1 D7 8D 8F FF C7 01 BD EE F4 A5 FA DB D4 C2 FC 01 00 A2 F7 F2 DD 05 C0 82 EA 0D
Received: DOWNLOAD CHANGESET(server_version=6, client_version=0, origin_timestamp=119025058030, origin_file_ident=2, original_changeset_size=215, changeset_size=215)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 05 6F 77 6E 65 72 3F 04 09 63 72 65 61 74 65 64 41 74 00 00 04 BD F9 DE AC C3 D1 DF 9F D0 01 F7 EC A4 D8 9A 88 A5 A3 EB 01 02 10 2F 5F 5F 63 6F 6E 66 69 67 75 72 61 74 69 6F 6E 06 02 01 BD F9 DE AC C3 D1 DF 9F D0 01 F7 EC A4 D8 9A 88 A5 A3 EB 01 00 04 66 75 6C 6C 06 02 02 BD F9 DE AC C3 D1 DF 9F D0 01 F7 EC A4 D8 9A 88 A5 A3 EB 01 00 07 64 65 66 61 75 6C 74 06 40 03 BD F9 DE AC C3 D1 DF 9F D0 01 F7 EC A4 D8 9A 88 A5 A3 EB 01 00 06 08 04 BD F9 DE AC C3 D1 DF 9F D0 01 F7 EC A4 D8 9A 88 A5 A3 EB 01 00 A2 F7 F2 DD 05 80 87 A7 0E
Received: DOWNLOAD CHANGESET(server_version=7, client_version=0, origin_timestamp=119025058068, origin_file_ident=2, original_changeset_size=180, changeset_size=180)
Changeset: 3F 00 04 55 73 65 72 3F 01 07 69 73 41 64 6D 69 6E 3F 02 07 41 63 63 6F 75 6E 74 3F 03 08 70 72 6F 76 69 64 65 72 3F 04 0A 70 72 6F 76 69 64 65 72 49 64 3F 05 08 61 63 63 6F 75 6E 74 73 00 00 04 8E C8 AA AB FC ED C0 8E EB 01 C1 AC DB FD BE E9 C9 A9 0C 02 07 5F 5F 61 64 6D 69 6E 06 01 01 8E C8 AA AB FC ED C0 8E EB 01 C1 AC DB FD BE E9 C9 A9 0C 00 01 00 02 04 02 00 00 06 02 03 02 00 00 05 72 65 61 6C 6D 06 02 04 02 00 00 07 5F 5F 61 64 6D 69 6E 00 00 01 05 8E C8 AA AB FC ED C0 8E EB 01 C1 AC DB FD BE E9 C9 A9 0C 02 0E 0C 00 00 02 02 00
Received: DOWNLOAD CHANGESET(server_version=8, client_version=0, origin_timestamp=119025058091, origin_file_ident=2, original_changeset_size=164, changeset_size=164)
Changeset: 3F 00 0A 50 65 72 6D 69 73 73 69 6F 6E 3F 01 04 75 73 65 72 3F 02 09 52 65 61 6C 6D 46 69 6C 65 3F 03 09 72 65 61 6C 6D 46 69 6C 65 3F 04 07 6D 61 79 52 65 61 64 3F 05 08 6D 61 79 57 72 69 74 65 3F 06 09 6D 61 79 4D 61 6E 61 67 65 3F 07 09 75 70 64 61 74 65 64 41 74 00 00 04 02 00 00 06 40 01 02 00 00 06 0C 03 02 00 00 02 B2 F8 DA D1 D7 8D 8F FF C7 01 BD EE F4 A5 FA DB D4 C2 FC 01 06 01 04 02 00 00 01 06 01 05 02 00 00 00 06 01 06 02 00 00 00 06 08 07 02 00 00 A2 F7 F2 DD 05 C0 99 B2 2B
Received: DOWNLOAD CHANGESET(server_version=9, client_version=0, origin_timestamp=119025058092, origin_file_ident=2, original_changeset_size=163, changeset_size=163)
Changeset: 3F 00 0A 50 65 72 6D 69 73 73 69 6F 6E 3F 01 04 75 73 65 72 3F 02 09 52 65 61 6C 6D 46 69 6C 65 3F 03 09 72 65 61 6C 6D 46 69 6C 65 3F 04 07 6D 61 79 52 65 61 64 3F 05 08 6D 61 79 57 72 69 74 65 3F 06 09 6D 61 79 4D 61 6E 61 67 65 3F 07 09 75 70 64 61 74 65 64 41 74 00 00 04 02 01 00 06 40 01 02 01 00 06 0C 03 02 01 00 02 D5 C0 D0 E0 A8 C1 8C EB EE 01 9A F3 F6 F5 D9 BE D2 99 37 06 01 04 02 01 00 01 06 01 05 02 01 00 00 06 01 06 02 01 00 00 06 08 07 02 01 00 A2 F7 F2 DD 05 80 9E EF 2B
Received: DOWNLOAD CHANGESET(server_version=10, client_version=0, origin_timestamp=119025058119, origin_file_ident=2, original_changeset_size=237, changeset_size=237)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 04 55 73 65 72 3F 04 05 6F 77 6E 65 72 3F 05 09 63 72 65 61 74 65 64 41 74 00 00 04 82 AD AB 8D A8 BD E3 D4 D9 01 FC DA CA A1 C6 CA F6 F0 EF 00 02 0B 2F 5F 5F 70 61 73 73 77 6F 72 64 06 02 01 82 AD AB 8D A8 BD E3 D4 D9 01 FC DA CA A1 C6 CA F6 F0 EF 00 00 04 66 75 6C 6C 06 02 02 82 AD AB 8D A8 BD E3 D4 D9 01 FC DA CA A1 C6 CA F6 F0 EF 00 00 07 64 65 66 61 75 6C 74 06 0C 04 82 AD AB 8D A8 BD E3 D4 D9 01 FC DA CA A1 C6 CA F6 F0 EF 00 00 03 8E C8 AA AB FC ED C0 8E EB 01 C1 AC DB FD BE E9 C9 A9 0C 06 08 05 82 AD AB 8D A8 BD E3 D4 D9 01 FC DA CA A1 C6 CA F6 F0 EF 00 00 A2 F7 F2 DD 05 C0 97 DF 38
Received: DOWNLOAD CHANGESET(server_version=11, client_version=0, origin_timestamp=119025058319, origin_file_ident=2, original_changeset_size=203, changeset_size=203)
Changeset: 3F 00 04 55 73 65 72 3F 01 07 69 73 41 64 6D 69 6E 3F 02 07 41 63 63 6F 75 6E 74 3F 03 08 70 72 6F 76 69 64 65 72 3F 04 0A 70 72 6F 76 69 64 65 72 49 64 3F 05 08 61 63 63 6F 75 6E 74 73 00 00 04 F5 B4 A5 81 FC F6 F9 EC C5 00 A8 A5 E5 DA ED F8 FD F7 E5 00 02 0B 72 65 61 6C 6D 2D 61 64 6D 69 6E 06 01 01 F5 B4 A5 81 FC F6 F9 EC C5 00 A8 A5 E5 DA ED F8 FD F7 E5 00 00 01 00 02 04 02 01 00 06 02 03 02 01 00 11 6A 77 74 2F 63 65 6E 74 72 61 6C 2D 6F 77 6E 65 72 06 02 04 02 01 00 0B 72 65 61 6C 6D 2D 61 64 6D 69 6E 00 00 01 05 F5 B4 A5 81 FC F6 F9 EC C5 00 A8 A5 E5 DA ED F8 FD F7 E5 00 02 0E 0C 00 00 02 02 01
Received: DOWNLOAD CHANGESET(server_version=12, client_version=0, origin_timestamp=119025076163, origin_file_ident=2, original_changeset_size=243, changeset_size=243)
Changeset: 3F 00 04 55 73 65 72 3F 01 07 69 73 41 64 6D 69 6E 3F 02 07 41 63 63 6F 75 6E 74 3F 03 08 70 72 6F 76 69 64 65 72 3F 04 0A 70 72 6F 76 69 64 65 72 49 64 3F 05 08 61 63 63 6F 75 6E 74 73 00 00 04 E7 AB C7 A5 E1 B6 BF C4 E9 01 D3 B0 F1 FF C9 F1 B1 BD D0 01 02 1F 73 79 73 74 65 6D 2D 61 63 63 65 73 73 69 62 69 6C 69 74 79 2D 74 65 73 74 73 2D 75 73 65 72 06 01 01 E7 AB C7 A5 E1 B6 BF C4 E9 01 D3 B0 F1 FF C9 F1 B1 BD D0 01 00 00 00 02 04 02 02 00 06 02 03 02 02 00 11 6A 77 74 2F 63 65 6E 74 72 61 6C 2D 61 64 6D 69 6E 06 02 04 02 02 00 1F 73 79 73 74 65 6D 2D 61 63 63 65 73 73 69 62 69 6C 69 74 79 2D 74 65 73 74 73 2D 75 73 65 72 00 00 01 05 E7 AB C7 A5 E1 B6 BF C4 E9 01 D3 B0 F1 FF C9 F1 B1 BD D0 01 02 0E 0C 00 00 02 02 02
Received: DOWNLOAD CHANGESET(server_version=13, client_version=0, origin_timestamp=119025559655, origin_file_ident=2, original_changeset_size=203, changeset_size=180)
Changeset: 3F 00 04 55 73 65 72 3F 01 07 69 73 41 64 6D 69 6E 3F 02 07 41 63 63 6F 75 6E 74 3F 03 08 70 72 6F 76 69 64 65 72 3F 04 0A 70 72 6F 76 69 64 65 72 49 64 3F 05 08 61 63 63 6F 75 6E 74 73 00 00 04 CA F1 CD DC 8C BF 9C DD 05 8F FD 81 EC E5 E0 A8 8C 3F 02 20 35 38 37 65 37 33 38 30 38 36 30 34 39 37 66 37 35 32 37 38 65 30 32 39 64 35 37 33 39 37 63 39 00 02 04 02 03 00 06 02 03 02 03 00 08 70 61 73 73 77 6F 72 64 06 02 04 02 03 00 05 61 64 6D 69 6E 00 00 01 05 CA F1 CD DC 8C BF 9C DD 05 8F FD 81 EC E5 E0 A8 8C 3F 02 0E 0C 00 00 02 02 03
Received: DOWNLOAD CHANGESET(server_version=14, client_version=0, origin_timestamp=119118101955, origin_file_ident=5, original_changeset_size=42, changeset_size=42)
Changeset: 3F 00 04 55 73 65 72 3F 01 07 69 73 41 64 6D 69 6E 00 00 06 01 01 CA F1 CD DC 8C BF 9C DD 05 8F FD 81 EC E5 E0 A8 8C 3F 00 01
Received: DOWNLOAD CHANGESET(server_version=15, client_version=0, origin_timestamp=119118127936, origin_file_ident=2, original_changeset_size=322, changeset_size=322)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 04 55 73 65 72 3F 04 05 6F 77 6E 65 72 3F 05 09 63 72 65 61 74 65 64 41 74 00 00 04 99 F1 D7 F8 83 8F 9D 9C C3 01 96 F3 C4 AC C6 B4 B3 89 B0 01 02 DC 00 2F 64 65 66 61 75 6C 74 2F 5F 5F 70 61 72 74 69 61 6C 2F 35 38 37 65 37 33 38 30 38 36 30 34 39 37 66 37 35 32 37 38 65 30 32 39 64 35 37 33 39 37 63 39 2F 64 39 32 66 32 64 30 34 65 61 36 37 64 62 65 30 33 66 65 30 32 39 36 63 63 33 33 38 65 62 38 63 61 35 37 32 66 31 61 37 06 02 01 99 F1 D7 F8 83 8F 9D 9C C3 01 96 F3 C4 AC C6 B4 B3 89 B0 01 00 07 70 61 72 74 69 61 6C 06 02 02 99 F1 D7 F8 83 8F 9D 9C C3 01 96 F3 C4 AC C6 B4 B3 89 B0 01 00 07 64 65 66 61 75 6C 74 06 0C 04 99 F1 D7 F8 83 8F 9D 9C C3 01 96 F3 C4 AC C6 B4 B3 89 B0 01 00 03 CA F1 CD DC 8C BF 9C DD 05 8F FD 81 EC E5 E0 A8 8C 3F 06 08 05 99 F1 D7 F8 83 8F 9D 9C C3 01 96 F3 C4 AC C6 B4 B3 89 B0 01 00 AF CE F8 DD 05 80 F4 A8 BE 03
Received: DOWNLOAD CHANGESET(server_version=16, client_version=0, origin_timestamp=119120628443, origin_file_ident=2, original_changeset_size=317, changeset_size=317)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 04 55 73 65 72 3F 04 05 6F 77 6E 65 72 3F 05 09 63 72 65 61 74 65 64 41 74 00 00 04 A6 C0 A4 C6 AA A3 E3 EC 2F 99 B7 CE BF D8 9E A6 CA C0 01 02 DC 00 2F 64 65 66 61 75 6C 74 2F 5F 5F 70 61 72 74 69 61 6C 2F 35 38 37 65 37 33 38 30 38 36 30 34 39 37 66 37 35 32 37 38 65 30 32 39 64 35 37 33 39 37 63 39 2F 37 65 35 36 38 34 36 33 36 66 39 63 62 31 32 31 35 32 35 63 64 62 66 38 31 32 33 39 31 32 64 36 31 30 66 39 62 38 62 30 06 02 01 A6 C0 A4 C6 AA A3 E3 EC 2F 99 B7 CE BF D8 9E A6 CA C0 01 00 07 70 61 72 74 69 61 6C 06 02 02 A6 C0 A4 C6 AA A3 E3 EC 2F 99 B7 CE BF D8 9E A6 CA C0 01 00 07 64 65 66 61 75 6C 74 06 0C 04 A6 C0 A4 C6 AA A3 E3 EC 2F 99 B7 CE BF D8 9E A6 CA C0 01 00 03 CA F1 CD DC 8C BF 9C DD 05 8F FD 81 EC E5 E0 A8 8C 3F 06 08 05 A6 C0 A4 C6 AA A3 E3 EC 2F 99 B7 CE BF D8 9E A6 CA C0 01 00 F4 E1 F8 DD 05 C0 C9 9E D3 01
Received: DOWNLOAD CHANGESET(server_version=17, client_version=0, origin_timestamp=119125943861, origin_file_ident=2, original_changeset_size=237, changeset_size=237)
Changeset: 3F 00 04 55 73 65 72 3F 01 07 69 73 41 64 6D 69 6E 3F 02 07 41 63 63 6F 75 6E 74 3F 03 08 70 72 6F 76 69 64 65 72 3F 04 0A 70 72 6F 76 69 64 65 72 49 64 3F 05 08 61 63 63 6F 75 6E 74 73 00 00 04 FB FF AB CD 89 DD 94 96 9C 01 D3 C3 DC DE BF E6 ED A0 D6 01 02 20 62 36 39 30 65 32 37 31 30 62 37 39 37 34 64 63 37 34 35 32 36 32 62 34 66 61 62 30 30 35 36 37 06 01 01 FB FF AB CD 89 DD 94 96 9C 01 D3 C3 DC DE BF E6 ED A0 D6 01 00 00 00 02 04 02 04 00 06 02 03 02 04 00 09 61 6E 6F 6E 79 6D 6F 75 73 06 02 04 02 04 00 20 30 37 31 62 32 66 35 38 33 66 35 35 31 36 34 35 34 30 32 35 64 61 37 33 62 33 66 63 62 30 63 62 00 00 01 05 FB FF AB CD 89 DD 94 96 9C 01 D3 C3 DC DE BF E6 ED A0 D6 01 02 0E 0C 00 00 02 02 04
Received: DOWNLOAD CHANGESET(server_version=18, client_version=0, origin_timestamp=119125944405, origin_file_ident=2, original_changeset_size=319, changeset_size=319)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 04 55 73 65 72 3F 04 05 6F 77 6E 65 72 3F 05 09 63 72 65 61 74 65 64 41 74 00 00 04 C0 84 EF F4 9A DF 9A 8F 3A F9 BB AC E9 8C B7 CB B9 E0 00 02 DC 00 2F 64 65 66 61 75 6C 74 2F 5F 5F 70 61 72 74 69 61 6C 2F 62 36 39 30 65 32 37 31 30 62 37 39 37 34 64 63 37 34 35 32 36 32 62 34 66 61 62 30 30 35 36 37 2F 63 61 39 38 33 37 30 61 37 64 32 37 65 36 65 66 31 35 64 30 32 33 62 61 61 39 61 38 64 39 61 66 65 37 30 65 39 61 32 35 06 02 01 C0 84 EF F4 9A DF 9A 8F 3A F9 BB AC E9 8C B7 CB B9 E0 00 00 07 70 61 72 74 69 61 6C 06 02 02 C0 84 EF F4 9A DF 9A 8F 3A F9 BB AC E9 8C B7 CB B9 E0 00 00 07 64 65 66 61 75 6C 74 06 0C 04 C0 84 EF F4 9A DF 9A 8F 3A F9 BB AC E9 8C B7 CB B9 E0 00 00 03 FB FF AB CD 89 DD 94 96 9C 01 D3 C3 DC DE BF E6 ED A0 D6 01 06 08 05 C0 84 EF F4 9A DF 9A 8F 3A F9 BB AC E9 8C B7 CB B9 E0 00 00 B8 8B F9 DD 05 C0 9E 8F C1 01
Received: DOWNLOAD CHANGESET(server_version=19, client_version=0, origin_timestamp=119221571875, origin_file_ident=2, original_changeset_size=237, changeset_size=237)
Changeset: 3F 00 04 55 73 65 72 3F 01 07 69 73 41 64 6D 69 6E 3F 02 07 41 63 63 6F 75 6E 74 3F 03 08 70 72 6F 76 69 64 65 72 3F 04 0A 70 72 6F 76 69 64 65 72 49 64 3F 05 08 61 63 63 6F 75 6E 74 73 00 00 04 FF E6 E6 8D A6 9F DC 85 B8 01 CC D9 B6 E9 B8 99 A4 98 DF 01 02 20 66 39 36 62 35 34 36 37 66 35 38 64 63 61 37 36 66 36 64 65 64 66 30 62 36 34 65 31 34 37 32 38 06 01 01 FF E6 E6 8D A6 9F DC 85 B8 01 CC D9 B6 E9 B8 99 A4 98 DF 01 00 00 00 02 04 02 05 00 06 02 03 02 05 00 09 61 6E 6F 6E 79 6D 6F 75 73 06 02 04 02 05 00 20 62 31 64 34 61 30 32 32 65 37 34 33 33 65 31 37 61 36 37 30 39 32 63 33 66 66 30 36 34 65 36 64 00 00 01 05 FF E6 E6 8D A6 9F DC 85 B8 01 CC D9 B6 E9 B8 99 A4 98 DF 01 02 0E 0C 00 00 02 02 05
Received: DOWNLOAD CHANGESET(server_version=20, client_version=0, origin_timestamp=119221573405, origin_file_ident=2, original_changeset_size=319, changeset_size=319)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 04 55 73 65 72 3F 04 05 6F 77 6E 65 72 3F 05 09 63 72 65 61 74 65 64 41 74 00 00 04 C0 E3 A0 CD C2 D2 E7 AD FD 01 A8 EB B2 F0 AC A7 FB 97 34 02 DC 00 2F 64 65 66 61 75 6C 74 2F 5F 5F 70 61 72 74 69 61 6C 2F 66 39 36 62 35 34 36 37 66 35 38 64 63 61 37 36 66 36 64 65 64 66 30 62 36 34 65 31 34 37 32 38 2F 33 33 61 31 62 62 30 64 62 63 33 61 34 64 65 39 65 65 63 63 66 34 62 63 34 38 61 62 63 39 32 62 32 61 37 38 61 61 37 30 06 02 01 C0 E3 A0 CD C2 D2 E7 AD FD 01 A8 EB B2 F0 AC A7 FB 97 34 00 07 70 61 72 74 69 61 6C 06 02 02 C0 E3 A0 CD C2 D2 E7 AD FD 01 A8 EB B2 F0 AC A7 FB 97 34 00 07 64 65 66 61 75 6C 74 06 0C 04 C0 E3 A0 CD C2 D2 E7 AD FD 01 A8 EB B2 F0 AC A7 FB 97 34 00 03 FF E6 E6 8D A6 9F DC 85 B8 01 CC D9 B6 E9 B8 99 A4 98 DF 01 06 08 05 C0 E3 A0 CD C2 D2 E7 AD FD 01 A8 EB B2 F0 AC A7 FB 97 34 00 C5 F6 FE DD 05 C0 9E 8F C1 01
Received: DOWNLOAD CHANGESET(server_version=21, client_version=0, origin_timestamp=119442393401, origin_file_ident=2, original_changeset_size=317, changeset_size=317)
Changeset: 3F 00 09 52 65 61 6C 6D 46 69 6C 65 3F 01 09 72 65 61 6C 6D 54 79 70 65 3F 02 09 73 79 6E 63 4C 61 62 65 6C 3F 03 04 55 73 65 72 3F 04 05 6F 77 6E 65 72 3F 05 09 63 72 65 61 74 65 64 41 74 00 00 04 D6 CB E6 D1 80 E9 B3 F3 CD 01 99 82 B2 C2 A8 95 C7 F2 15 02 DC 00 2F 64 65 66 61 75 6C 74 2F 5F 5F 70 61 72 74 69 61 6C 2F 35 38 37 65 37 33 38 30 38 36 30 34 39 37 66 37 35 32 37 38 65 30 32 39 64 35 37 33 39 37 63 39 2F 31 61 38 64 30 31 32 30 30 65 36 64 31 38 35 63 31 64 66 62 31 38 37 64 66 64 31 61 31 39 62 36 65 64 62 36 33 35 34 62 06 02 01 D6 CB E6 D1 80 E9 B3 F3 CD 01 99 82 B2 C2 A8 95 C7 F2 15 00 07 70 61 72 74 69 61 6C 06 02 02 D6 CB E6 D1 80 E9 B3 F3 CD 01 99 82 B2 C2 A8 95 C7 F2 15 00 07 64 65 66 61 75 6C 74 06 0C 04 D6 CB E6 D1 80 E9 B3 F3 CD 01 99 82 B2 C2 A8 95 C7 F2 15 00 03 CA F1 CD DC 8C BF 9C DD 05 8F FD 81 EC E5 E0 A8 8C 3F 06 08 05 D6 CB E6 D1 80 E9 B3 F3 CD 01 99 82 B2 C2 A8 95 C7 F2 15 00 D9 B3 8C DE 05 C0 8C 9B BF 01
Connection[1]: Session[1]: Received: DOWNLOAD(download_server_version=21, download_client_version=0, latest_server_version=21, latest_server_version_salt=7217337837575967989, upload_client_version=0, upload_server_version=0, downloadable_bytes=4920, num_changesets=21, ...)
Using already open Realm file: Path\realm-object-server\listener\realms.realm
I am trying to read files in a directory, for each file I am converting it into bytes array and appending everything in combinedBuffer array. Now I want to add all bytes buffer in combinedBuffer to finalBuffer, But I am not able to achieve this, it just iterate over the first bytes buffer in combinedBuffer rather than iterating over the entire combinedBuffer Array.
fileRead = async function(file){
const testFolder = './items/';
var dirFiles = [] // dirFiles Array
fs.readdirSync(testFolder).forEach(file => {
dirFiles.push(file)
})
dirFiles.sort(compareBasedonInt) //Natural Compare is to sort files in sampleFile1, SampleFile2.
var combinedBuffer = []
dirFiles.forEach(function(file){
var eachfileBuffer= fs.readFileSync('./items/'+file) //eachfileBuffer is the bytes buffer which we get after reading the file
combinedBuffer.push(eachfileBuffer)
})
var finalbuffer = Buffer.concat(combinedBuffer)
console.log("final buffer", finalbuffer) // finalBuffer shows just first element of combinedBuffer
console.log("combinedBuffer", combinedBuffer) // shows the array of all the bytes buffer
}
Output
combinedBuffer [ <Buffer 2f 51 40 42 0b 0a 53 0c 4a 25 05 55 7f 06 32 79 0d 50 47 0c 5d 3e 59 0b 51 54 40 5c 4a 5e 53 4f 15 05 4d 1f 41 4e 23 07 1f 52 5f 1f 52 48 14 52 4e 52 ... >,
<Buffer 19 42 01 0d 46 59 4a 58 1a 38 60 06 4a 11 2d 5c 70 65 2e 5a 17 0f 54 14 09 2a 05 14 38 34 47 0f 0e 42 5f 26 56 49 07 19 12 11 5e 4e 01 55 0b 41 26 72 ... >,
<Buffer 17 1a 11 5d 4d 19 1e 44 45 45 57 5f 05 49 19 1a 18 2a 23 27 46 00 47 45 17 45 1c 4f 5b 4f 4b 53 45 55 3e 4b 1d 08 4b 15 1a 1c 18 66 50 1a 4f 55 18 05 ... >,
<Buffer 44 0a 06 50 16 10 58 1b 15 40 07 22 58 0b 51 4e 08 07 46 6f 7c 66 12 57 4e 1d 1b 09 04 4a 40 4f 1e 11 5f 41 41 74 62 5f 76 43 5e 0d 1a 01 1a 0c 7d 44 ... >,
<Buffer 3c 09 5f 5c 6c 15 5c 02 15 5d 00 40 03 09 46 54 49 16 5c 5a ff 9f a2 45 43 00 46 46 65 1b 11 5c 5d 54 29 46 44 07 02 14 45 4b 31 6a 3a 4d 0a 58 18 47 ... >,
<Buffer 6d 4a 19 1b 85 bd ec 0c 0f 0f 4c 4a 41 08 09 1b 4f 0b 0a 1d 41 11 53 4b 1e 41 49 1e ce aa ad 11 22 1d 0f 52 46 1b 7a 0b 0e 15 1e 41 53 02 10 19 4f 01 ... >,
<Buffer 03 58 69 48 04 5f 52 02 08 56 1f 07 76 4e 1d 53 12 5e 5e 58 47 0a 5a 44 77 06 16 5e 03 4a 4d 56 56 01 1f 0b 0c 0c 40 45 0e 0c 4e 08 1b 12 1a 45 4e 50 ... >,
<Buffer 4d 5c 0c 4e 1d c2 a2 f9 1b 11 16 5f 52 00 0c 02 54 40 4d 17 0d 58 4c 1b 24 5b 12 41 4b 47 1a 0a 43 50 7c 6d 34 46 42 5a 43 42 43 38 1b 4b 53 57 5f 43 ... >,
<Buffer 49 4e 1a 13 1c 19 0b 0a 5d 19 41 46 06 14 15 51 15 15 56 57 1c 5d 09 1e 00 41 4a 6f 13 0a 60 60 64 16 4c 01 1e 49 46 0e 50 1d 51 56 5c 09 0e 37 16 12 ... >,
<Buffer 58 1d 4f 5b 4c 33 09 4f 08 19 04 1b 69 7e 2d 5d 22 95 be 8b 14 1b 76 4b 07 21 1f 4f 05 4b 30 2e 02 57 07 00 4d 5f 45 1c 08 39 37 37 41 47 25 09 05 4d ... >,
<Buffer 58 42 43 1f 5e 1e 01 17 54 04 52 1c 1a 04 42 48 52 48 3e 03 05 12 4c 16 5a 49 7e 14 49 53 1a 6f 6f 2f 46 54 54 07 00 7a 23 0a 1c 3b 56 0f 73 0a 00 0b ... >]
finalbuffer <Buffer 2f 51 40 42 0b 0a 53 0c 4a 25 05 55 7f 06 32 79 0d 50 47 0c 5d 3e 59 0b 51 54 40 5c 4a 5e 53 4f 15 05 4d 1f 41 4e 23 07 1f 52 5f 1f 52 48 14 52 4e 52 ... >
This question already has answers here:
How to remove ^[, and all of the escape sequences in a file using linux shell scripting
(14 answers)
Closed 4 years ago.
I have a file on a Linux machine which contains many hidden characters which are as follows :
$ cat -v file.txt
^[[2J^[[?7l^[[3;23r^[[?6l^[[1;1H^[[?25l^[[1;1HLogging into the device
Software revision V1.0
Copyright All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
ABC, COMPANY
^[[1;24r^[[1;1H^[[44;1HPress any key to continue^[[44;1H^[[?
25h^[[44;27H^[[2J^[[?7l^[[1;24r^[[?
6l^[[44;27H^[[1;44r^[[44;1H^[[44;1H^[[2K^[[44;1H^[[?25h^[[44;1H^[[44;1HMH
5 percent busy, from 388 sec ago
1 sec ave: 4 percent busy
5 sec ave: 16 percent busy
1 min ave: 7 percent busy
^[[1;44r^[[44;1H^[[44;1H^[[2K^[[44;1H^[[?25h^[[44;1H^[[44;1My-Device-SW>
^[[44;1H^[[44;11H^[[44;1H^[[?
25h^[[44;11H^[[44;0H^[E^[[44;1H^[[44;11H^[[44;1H^[[2K^[[44;1H^[[?.
Earlier there were some ^M characters which I removed using :
sed 's/^M//g' file.txt
I want to remove only the hidden characters so that my actual file looks like :
$ cat file.txt
Logging into the device
Software revision V1.0
Copyright All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
ABC, COMPANY
Press any key to continue
My-Device-SW>
My-Device-show CPU
5 percent busy, from 388 sec ago
1 sec ave: 4 percent busy
5 sec ave: 16 percent busy
1 min ave: 7 percent busy
My-Device-SW>
My-Device-exit
Do you want to log out [y/n]? y
Connection to My-Device-SW closed.
Also posting the output of hexdump -C file.txt :
$ hexdump -C file.txt
00000000 1b 5b 32 4a 1b 5b 3f 37 6c 1b 5b 33 3b 32 33 72 |.[2J.[?7l.[3;23r|
00000010 1b 5b 3f 36 6c 1b 5b 31 3b 31 48 1b 5b 3f 32 35 |.[?6l.[1;1H.[?25|
00000020 6c 1b 5b 31 3b 31 48 4c 6f 67 67 69 6e 67 20 69 |l.[1;1HLogging i|
00000030 6e 74 6f 20 74 68 65 20 64 65 76 69 63 65 0a 53 |nto the device.S|
00000040 6f 66 74 77 61 72 65 20 72 65 76 69 73 69 6f 6e |oftware revision|
00000050 20 56 31 2e 30 0a 43 6f 70 79 72 69 67 68 74 20 | V1.0.Copyright |
00000060 41 6c 6c 20 52 69 67 68 74 73 20 52 65 73 65 72 |All Rights Reser|
00000070 76 65 64 2e 0a 20 20 20 20 20 20 20 20 20 20 20 |ved.. |
00000080 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000090 52 45 53 54 52 49 43 54 45 44 20 52 49 47 48 54 |RESTRICTED RIGHT|
000000a0 53 20 4c 45 47 45 4e 44 0a 20 55 73 65 2c 20 64 |S LEGEND. Use, d|
000000b0 75 70 6c 69 63 61 74 69 6f 6e 2c 20 6f 72 20 64 |uplication, or d|
000000c0 69 73 63 6c 6f 73 75 72 65 20 62 79 20 74 68 65 |isclosure by the|
000000d0 20 47 6f 76 65 72 6e 6d 65 6e 74 20 69 73 20 73 | Government is s|
000000e0 75 62 6a 65 63 74 20 74 6f 20 72 65 73 74 72 69 |ubject to restri|
000000f0 63 74 69 6f 6e 73 0a 20 20 20 20 20 20 20 20 20 |ctions. |
00000100 41 42 43 2c 20 43 4f 4d 50 41 4e 59 0a 1b 5b 31 |ABC, COMPANY..[1|
00000110 3b 32 34 72 1b 5b 31 3b 31 48 1b 5b 34 34 3b 31 |;24r.[1;1H.[44;1|
00000120 48 50 72 65 73 73 20 61 6e 79 20 6b 65 79 20 74 |HPress any key t|
00000130 6f 20 63 6f 6e 74 69 6e 75 65 1b 5b 34 34 3b 31 |o continue.[44;1|
00000140 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b 32 37 48 1b |H.[?25h.[44;27H.|
00000150 5b 32 4a 1b 5b 3f 37 6c 1b 5b 31 3b 32 34 72 1b |[2J.[?7l.[1;24r.|
00000160 5b 3f 36 6c 1b 5b 34 34 3b 32 37 48 1b 5b 31 3b |[?6l.[44;27H.[1;|
00000170 34 34 72 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 |44r.[44;1H.[44;1|
00000180 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 |H.[2K.[44;1H.[?2|
00000190 35 68 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 48 |5h.[44;1H.[44;1H|
000001a0 4d 79 2d 44 65 76 69 63 65 2d 53 57 3e 20 1b 5b |My-Device-SW> .[|
000001b0 34 34 3b 31 48 1b 5b 34 34 3b 31 31 48 1b 5b 34 |44;1H.[44;11H.[4|
000001c0 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 |4;1H.[?25h.[44;1|
000001d0 31 48 1b 5b 34 34 3b 30 48 1b 45 1b 5b 34 34 3b |1H.[44;0H.E.[44;|
000001e0 31 48 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 |1H.[44;11H.[44;1|
000001f0 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 |H.[2K.[44;1H.[?2|
00000200 35 68 1b 5b 34 34 3b 31 48 1b 5b 31 3b 34 34 72 |5h.[44;1H.[1;44r|
00000210 1b 5b 34 34 3b 31 48 1b 5b 31 3b 34 34 72 1b 5b |.[44;1H.[1;44r.[|
00000220 34 34 3b 31 48 1b 5b 34 34 3b 31 48 1b 5b 32 4b |44;1H.[44;1H.[2K|
00000230 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 |.[44;1H.[?25h.[4|
00000240 34 3b 31 48 1b 5b 34 34 3b 31 48 4d 79 2d 44 65 |4;1H.[44;1HMy-De|
00000250 76 69 63 65 2d 53 57 3e 20 1b 5b 34 34 3b 31 48 |vice-SW> .[44;1H|
00000260 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 48 1b |.[44;11H.[44;1H.|
00000270 5b 3f 32 35 68 1b 5b 34 34 3b 31 31 48 1b 5b 34 |[?25h.[44;11H.[4|
00000280 34 3b 31 31 48 73 68 6f 77 20 43 50 55 1b 5b 34 |4;11Hshow CPU.[4|
00000290 34 3b 31 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b |4;11H.[?25h.[44;|
000002a0 31 39 48 1b 5b 34 34 3b 30 48 1b 45 1b 5b 34 34 |19H.[44;0H.E.[44|
000002b0 3b 31 48 1b 5b 34 34 3b 31 39 48 1b 5b 34 34 3b |;1H.[44;19H.[44;|
000002c0 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f |1H.[2K.[44;1H.[?|
000002d0 32 35 68 1b 5b 34 34 3b 31 48 1b 5b 31 3b 34 34 |25h.[44;1H.[1;44|
000002e0 72 1b 5b 34 34 3b 31 48 0a 35 20 70 65 72 63 65 |r.[44;1H.5 perce|
000002f0 6e 74 20 62 75 73 79 2c 20 66 72 6f 6d 20 33 38 |nt busy, from 38|
00000300 38 20 73 65 63 20 61 67 6f 0a 31 20 73 65 63 20 |8 sec ago.1 sec |
00000310 61 76 65 3a 20 34 20 70 65 72 63 65 6e 74 20 62 |ave: 4 percent b|
00000320 75 73 79 0a 35 20 73 65 63 20 61 76 65 3a 20 31 |usy.5 sec ave: 1|
00000330 36 20 70 65 72 63 65 6e 74 20 62 75 73 79 0a 31 |6 percent busy.1|
00000340 20 6d 69 6e 20 61 76 65 3a 20 37 20 70 65 72 63 | min ave: 7 perc|
00000350 65 6e 74 20 62 75 73 79 0a 1b 5b 31 3b 34 34 72 |ent busy..[1;44r|
00000360 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 48 1b 5b |.[44;1H.[44;1H.[|
00000370 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b |2K.[44;1H.[?25h.|
00000380 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 4d 79 2d 44 |[44;1H.[44;1My-D|
00000390 65 76 69 63 65 2d 53 57 3e 20 1b 5b 34 34 3b 31 |evice-SW> .[44;1|
000003a0 48 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 48 |H.[44;11H.[44;1H|
000003b0 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 31 48 1b 5b |.[?25h.[44;11H.[|
000003c0 34 34 3b 30 48 1b 45 1b 5b 34 34 3b 31 48 1b 5b |44;0H.E.[44;1H.[|
000003d0 34 34 3b 31 31 48 1b 5b 34 34 3b 31 48 1b 5b 32 |44;11H.[44;1H.[2|
000003e0 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b |K.[44;1H.[?25h.[|
000003f0 34 34 3b 31 48 1b 5b 31 3b 34 34 72 1b 5b 34 34 |44;1H.[1;44r.[44|
00000400 3b 31 48 1b 5b 31 3b 34 34 72 1b 5b 34 34 3b 31 |;1H.[1;44r.[44;1|
00000410 48 1b 5b 34 34 3b 31 48 1b 5b 32 4b 1b 5b 34 34 |H.[44;1H.[2K.[44|
00000420 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 48 |;1H.[?25h.[44;1H|
00000430 1b 5b 34 34 3b 31 48 4d 79 2d 44 65 76 69 63 65 |.[44;1HMy-Device|
00000440 2d 53 57 3e 20 1b 5b 34 34 3b 31 48 1b 5b 34 34 |-SW> .[44;1H.[44|
00000450 3b 31 31 48 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 |;11H.[44;1H.[?25|
00000460 68 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 31 |h.[44;11H.[44;11|
00000470 48 65 78 69 74 1b 5b 34 34 3b 31 31 48 1b 5b 3f |Hexit.[44;11H.[?|
00000480 32 35 68 1b 5b 34 34 3b 31 35 48 1b 5b 34 34 3b |25h.[44;15H.[44;|
00000490 30 48 1b 45 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b |0H.E.[44;1H.[44;|
000004a0 31 35 48 1b 5b 34 34 3b 31 48 1b 5b 32 4b 1b 5b |15H.[44;1H.[2K.[|
000004b0 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b |44;1H.[?25h.[44;|
000004c0 31 48 1b 5b 31 3b 34 34 72 1b 5b 34 34 3b 31 48 |1H.[1;44r.[44;1H|
000004d0 1b 5b 31 3b 34 34 72 1b 5b 34 34 3b 31 48 1b 5b |.[1;44r.[44;1H.[|
000004e0 34 34 3b 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 |44;1H.[2K.[44;1H|
000004f0 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 48 1b 5b 34 |.[?25h.[44;1H.[4|
00000500 34 3b 31 48 44 6f 20 79 6f 75 20 77 61 6e 74 20 |4;1HDo you want |
00000510 74 6f 20 6c 6f 67 20 6f 75 74 20 5b 79 2f 6e 5d |to log out [y/n]|
00000520 3f 20 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 33 31 |? .[44;1H.[44;31|
00000530 48 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b |H.[44;1H.[?25h.[|
00000540 34 34 3b 33 31 48 1b 5b 34 34 3b 33 31 48 79 1b |44;31H.[44;31Hy.|
00000550 5b 34 34 3b 33 31 48 1b 5b 3f 32 35 68 1b 5b 34 |[44;31H.[?25h.[4|
00000560 34 3b 33 32 48 1b 5b 34 34 3b 30 48 1b 45 1b 5b |4;32H.[44;0H.E.[|
00000570 34 34 3b 31 48 1b 5b 34 34 3b 33 32 48 1b 5b 34 |44;1H.[44;32H.[4|
00000580 34 3b 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b |4;1H.[2K.[44;1H.|
00000590 5b 3f 32 35 68 1b 5b 34 34 3b 31 48 1b 5b 31 3b |[?25h.[44;1H.[1;|
000005a0 34 34 72 1b 5b 34 34 3b 31 48 1b 5b 32 4a 1b 5b |44r.[44;1H.[2J.[|
000005b0 3f 37 6c 1b 5b 31 3b 34 34 72 1b 5b 3f 36 6c 1b |?7l.[1;44r.[?6l.|
000005c0 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 |[44;1H.[?25h.[44|
000005d0 3b 31 48 1b 5b 3f 36 6c 1b 5b 31 3b 30 72 1b 5b |;1H.[?6l.[1;0r.[|
000005e0 3f 37 6c 1b 5b 32 4a 1b 5b 34 34 3b 31 48 1b 5b |?7l.[2J.[44;1H.[|
000005f0 31 3b 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 43 |1;1H.[2K.[44;1HC|
00000600 6f 6e 6e 65 63 74 69 6f 6e 20 74 6f 20 4d 79 2d |onnection to My-|
00000610 44 65 76 69 63 65 2d 53 57 20 63 6c 6f 73 65 64 |Device-SW closed|
00000620 2e 0a |..|
00000622
Can someone please help me out in this?
Modifying with the actual file content above.
Are you using text files created under windows on Linux?. In that case you must install "tofrodos" package in your Linux distro, and then use "fromdos" tool to convert files from windows to linux format:
$ fromdos <windows-file-format.txt>
This will generate an alert:
alert tcp any any <> any any (msg:"Test_A"; sid:3000001; rev:1;)
This will not:
alert tcp any any <> any any (msg:"Test_B"; content:"badurl.com"; http_header; sid:3000002; rev:1;)
I have tried: fast_pattern:only; metadata:service http; nocase; http_header; and others. I cannot get it to work at this generic level. Any ideas why the content attribute does not work? The packet has a URL.
Updated from the comments
0000 9c d2 4b 7d 96 60 3c 15 c2 dc 48 fa 08 00 45 00 ..K}.<. ..H...E.
0010 01 5c ac 2c 40 00 40 06 cf f5 c0 a8 c8 1e 41 fe .\.,#.#. ......A.
0020 f2 b4 dc 41 00 50 d0 e7 97 d0 ae b8 f9 ba 80 18 ...A.P.. ........
0030 ff ff da 1f 00 00 01 01 08 0a 34 03 84 d8 b7 cc ........ ..4.....
0040 3f 04 47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 ?.GET / HTTP/1.1
0050 0d 0a 48 6f 73 74 3a 20 6d 79 64 6f 6d 61 69 6e ..Host: mydomain
0060 2e 63 6f 6d 0d 0a 55 73 65 72 2d 41 67 65 6e 74 .com..Us er-Agent
The rule that you have provided will never fire with the example packet that you have provided. You have used a content:"POST"; with a http_method modifier but you are attempting to match a packet that is a GET request.
I think that the right content modifier should be http_uri, not http_header. Unless you are trying to capture the Host POST parameter.
I am going to try to write simple BitTorrent client. Of course I read http://wiki.theory.org/BitTorrentSpecification. I began by analyzing communication between two clients. I have problem with meaning of two fields - bold font in the following hexadecimal dump.
First packet send by Deluge to rTorrent:
00000000 13 |. | - protocol name length (1) - 0x13 = 19
00000000 42 69 74 54 6f 72 72 65 6e 74 20 70 72 6f 74 | BitTorrent prot| - protocol name (19)
00000010 6f 63 6f 6c |ocol |
00000010 00 00 00 00 00 18 00 05 | ........ | - reserved extension bytes (8)
00000010 ab 20 ef 66 | . .f| - info_hash (20)
00000020 c8 ee de 47 99 a2 75 40 20 75 ee 7b c6 4e 2f dd |...G..u# u.{.N/.|
00000030 2d 44 45 31 33 33 30 2d 42 6c 78 37 6c 69 7a 7e |-DE1330-Blx7liz~| - peer_id (20)
00000040 4a 54 2e 6a |JT.j| Deluge 1.3.3
Answer from rTorrent to Deluge:
00000000 13 |. | - protocol name length (1) - 0x13 = 19
00000000 42 69 74 54 6f 72 72 65 6e 74 20 70 72 6f 74 | BitTorrent prot| - protocol name (19)
00000010 6f 63 6f 6c |ocol |
00000010 00 00 00 00 00 10 00 00 | ........ | - reserved extension bytes (8)
00000010 ab 20 ef 66 | . .f| - info_hash (20)
00000020 c8 ee de 47 99 a2 75 40 20 75 ee 7b c6 4e 2f dd |...G..u# u.{.N/.|
00000030 2d 6c 74 30 43 39 30 2d b6 eb 22 ae 31 e3 89 90 |-lt0C90-..".1...| - peer_id (20)
00000040 2a 9b af a9 |*... | libTorrent (rakshasa) 0.12.9
00000040 00 00 00 6e | ...n | - message length? (4) - 0x6E = 110
00000040 14 00 | .. | - something (2) - message id?
00000040 64 31 3a 65 69 30 | d1:ei0| - bencoded dictionary (108)
00000050 65 31 3a 6d 64 31 31 3a 75 74 5f 6d 65 74 61 64 |e1:md11:ut_metad| { 'e': 0,
00000060 61 74 61 69 32 65 36 3a 75 74 5f 70 65 78 69 31 |atai2e6:ut_pexi1| 'metadata_size': 1702,
00000070 65 65 31 33 3a 6d 65 74 61 64 61 74 61 5f 73 69 |ee13:metadata_si| 'm': {'ut_metadata': 2, 'ut_pex': 1},
00000080 7a 65 69 31 37 30 32 65 31 3a 70 69 35 30 30 39 |zei1702e1:pi5009| 'reqq': 2048,
00000090 34 65 34 3a 72 65 71 71 69 32 30 34 38 65 31 3a |4e4:reqqi2048e1:| 'p': 50094,
000000a0 76 31 37 3a 6c 69 62 54 6f 72 72 65 6e 74 20 30 |v17:libTorrent 0| 'v': 'libTorrent 0.12.9' }
000000b0 2e 31 32 2e 39 65 |.12.9e |
000000b0 00 00 00 0c 05 | .....| - something (5) - checksum?