måndag 23 maj 2022 kl. 08:09:48 UTC+2 skrev mike:<ssh><tcp-server-parameters><local-address>0.0.0.0</local-address><keepalives><idle-time>1</idle-time><max-probes>10</max-probes><probe-interval>5</probe-interval></keepalives></tcp-server-parameters><ssh-server-parameters><server-identity><host-key><
Hi,
We receive a message called "chunked message" in NETCONF.
Example:
final String MSG_REPLY = "#877\r\n"
+
"<rpc-reply message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><netconf-server xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-server\"><listen><endpoint><name>default-ssh</name>
+
"##\r\n";
I tried:
String newline = System.getProperty("line.separator");//make sure I get newline for platform.
return sb.toString().contains(newline + "##" + newline);
But it fails. Is it possible to check if the string ends with a regex pattern?
//mikeI even checked the ASCII in my buffer.
ASCII numbers is:
10 LF
35 #
35 #
10 LF
I changed my regexp:
sb.toString().matches("(?s).*\\r\\n|\\n##\\r\\n|\\n$")
but it still evaluates to false. I suspect it is DOT ALL that gives me the headache.
//mike
Hi,default-key</name><public-key><keystore-reference>genkey</keystore-reference></public-key></host-key></server-identity><client-authentication><supported-authentication-methods><publickey/><passsword/><other>interactive</other></supported-authentication-
We receive a message called "chunked message" in NETCONF.
Example:
final String MSG_REPLY = "#877\r\n"
+
"<rpc-reply message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><netconf-server xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-server\"><listen><endpoint><name>default-ssh</name><
<tcp-server-parameters><local-address>0.0.0.0</local-address><keepalives><idle-time>1</idle-time><max-probes>10</max-probes><probe-interval>5</probe-interval></keepalives></tcp-server-parameters><ssh-server-parameters><server-identity><host-key><name>
+
"##\r\n";
I tried:
String newline = System.getProperty("line.separator");//make sure I get newline for platform.
return sb.toString().contains(newline + "##" + newline);
But it fails. Is it possible to check if the string ends with a regex pattern?
//mike
måndag 23 maj 2022 kl. 11:32:07 UTC+2 skrev mike:name><ssh><tcp-server-parameters><local-address>0.0.0.0</local-address><keepalives><idle-time>1</idle-time><max-probes>10</max-probes><probe-interval>5</probe-interval></keepalives></tcp-server-parameters><ssh-server-parameters><server-identity><host-key>
måndag 23 maj 2022 kl. 08:09:48 UTC+2 skrev mike:
Hi,
We receive a message called "chunked message" in NETCONF.
Example:
final String MSG_REPLY = "#877\r\n"
+
"<rpc-reply message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><netconf-server xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-server\"><listen><endpoint><name>default-ssh</
+
"##\r\n";
I tried:
String newline = System.getProperty("line.separator");//make sure I get newline for platform.
return sb.toString().contains(newline + "##" + newline);
But it fails. Is it possible to check if the string ends with a regex pattern?
//mikeI even checked the ASCII in my buffer.
ASCII numbers is:
10 LF
35 #
35 #
10 LF
I changed my regexp:
sb.toString().matches("(?s).*\\r\\n|\\n##\\r\\n|\\n$")
but it still evaluates to false. I suspect it is DOT ALL that gives me the headache.
//mikeEven tried this to make sure I have only four last characters of my string.
String endofMsg = sb.toString().substring(sb.toString().length() - 4);
return endofMsg.matches("^\\r\\n|[\\n]##\\r\\n|[\\n]$");
I found out I can do:
String endofMsg = sb.toString().substring(sb.toString().length() - 6); return endofMsg.matches("\\r\\n##\\r\\n|.*\\n##\\n$");
I had to use the last 6 characters since newline is different for each platform.
//mike
different. *nix uses \n for linefeed, Windows uses \r\n , so you're checking for the presence of \n if you want to check for a linefeed.I found out I can do:
String endofMsg = sb.toString().substring(sb.toString().length() - 6);
return endofMsg.matches("\\r\\n##\\r\\n|.*\\n##\\n$");
I had to use the last 6 characters since newline is different for each platform.
//mike
I'm not clear what is the problem you're trying to solve, but System.getProperty("line.separator") is system dependent, so if you're running that on one system to get a value to use on a different system, your value will be wrong if the systems are
måndag 23 maj 2022 kl. 12:00:06 UTC+2 skrev mike:name><ssh><tcp-server-parameters><local-address>0.0.0.0</local-address><keepalives><idle-time>1</idle-time><max-probes>10</max-probes><probe-interval>5</probe-interval></keepalives></tcp-server-parameters><ssh-server-parameters><server-identity><host-key>
måndag 23 maj 2022 kl. 11:32:07 UTC+2 skrev mike:
måndag 23 maj 2022 kl. 08:09:48 UTC+2 skrev mike:
We receive a message called "chunked message" in NETCONF.
Example:
final String MSG_REPLY = "#877\r\n"
+
"<rpc-reply message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><netconf-server xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-server\"><listen><endpoint><name>default-ssh</
Even tried this to make sure I have only four last characters of my string. >>+I even checked the ASCII in my buffer.
"##\r\n";
I tried:
String newline = System.getProperty("line.separator");//make sure I get newline for platform.
return sb.toString().contains(newline + "##" + newline);
But it fails. Is it possible to check if the string ends with a regex pattern?
//mike
ASCII numbers is:
10 LF
35 #
35 #
10 LF
I changed my regexp:
sb.toString().matches("(?s).*\\r\\n|\\n##\\r\\n|\\n$")
but it still evaluates to false. I suspect it is DOT ALL that gives me the headache.
String endofMsg = sb.toString().substring(sb.toString().length() - 4);
return endofMsg.matches("^\\r\\n|[\\n]##\\r\\n|[\\n]$");
I found out I can do:
String endofMsg = sb.toString().substring(sb.toString().length() - 6);
return endofMsg.matches("\\r\\n##\\r\\n|.*\\n##\\n$");
I had to use the last 6 characters since newline is different for each platform.
I changed my regexp:
sb.toString().matches("(?s).*\\r\\n|\\n##\\r\\n|\\n$")
but it still evaluates to false. I suspect it is DOT ALL that gives me the headache.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 495 |
Nodes: | 16 (2 / 14) |
Uptime: | 46:54:15 |
Calls: | 9,745 |
Calls today: | 5 |
Files: | 13,742 |
Messages: | 6,184,379 |