Update dependencies and build container.
This commit is contained in:
parent
cf377adecd
commit
3e21ea395e
12
build.gradle
12
build.gradle
|
@ -12,14 +12,14 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
annotationProcessor 'info.picocli:picocli-codegen:4.6.3'
|
||||
implementation 'info.picocli:picocli:4.6.3'
|
||||
implementation 'org.slf4j:slf4j-api:2.0.3'
|
||||
implementation 'org.slf4j:slf4j-simple:2.0.3'
|
||||
annotationProcessor 'info.picocli:picocli-codegen:4.7.0'
|
||||
implementation 'info.picocli:picocli:4.7.0'
|
||||
implementation 'org.slf4j:slf4j-api:2.0.5'
|
||||
implementation 'org.slf4j:slf4j-simple:2.0.5'
|
||||
|
||||
testImplementation 'org.spockframework:spock-core:2.3-groovy-3.0'
|
||||
testImplementation 'org.slf4j:slf4j-api:2.0.3'
|
||||
testRuntimeOnly 'org.slf4j:slf4j-simple:2.0.3'
|
||||
testImplementation 'org.slf4j:slf4j-api:2.0.5'
|
||||
testRuntimeOnly 'org.slf4j:slf4j-simple:2.0.5'
|
||||
}
|
||||
|
||||
application {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
id = syslogd
|
||||
group = biz.nellemann.syslogd
|
||||
version = 1.2.7
|
||||
version = 1.2.8
|
||||
|
|
|
@ -168,8 +168,7 @@ public class Application implements Callable<Integer>, LogReceiveListener {
|
|||
|
||||
|
||||
private InetSocketAddress getInetSocketAddress(URI input) {
|
||||
InetSocketAddress inetSocketAddress = new InetSocketAddress(input.getHost(), input.getPort());
|
||||
return inetSocketAddress;
|
||||
return new InetSocketAddress(input.getHost(), input.getPort());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public class SyslogPrinter {
|
|||
sb.append(String.format(" \"level\": \"%s\",", msg.severity));
|
||||
sb.append(String.format(" \"application\": \"%s\"", msg.application));
|
||||
sb.append("}, \"values\": [ ");
|
||||
sb.append(String.format("[ \"%d\", \"%s\" ]", msg.timestamp.getEpochSecond() * 1000000000l, getMessageLine(msg)));
|
||||
sb.append(String.format("[ \"%d\", \"%s\" ]", msg.timestamp.getEpochSecond() * 1000000000L, getMessageLine(msg)));
|
||||
sb.append(" ] } ] }");
|
||||
log.debug(sb.toString());
|
||||
return sb.toString();
|
||||
|
|
|
@ -29,8 +29,8 @@ public class UdpClient implements LogForwardListener {
|
|||
|
||||
private final static Logger log = LoggerFactory.getLogger(UdpClient.class);
|
||||
|
||||
private InetSocketAddress inetSocketAddress;
|
||||
private DatagramSocket socket;
|
||||
private final InetSocketAddress inetSocketAddress;
|
||||
private final DatagramSocket socket;
|
||||
|
||||
public UdpClient(InetSocketAddress inetSocketAddress) throws SocketException {
|
||||
this.inetSocketAddress = inetSocketAddress;
|
||||
|
@ -40,14 +40,12 @@ public class UdpClient implements LogForwardListener {
|
|||
public void send(String msg) {
|
||||
byte[] buf = msg.getBytes(StandardCharsets.US_ASCII);
|
||||
DatagramPacket packet = new DatagramPacket(buf, buf.length, inetSocketAddress.getAddress(), inetSocketAddress.getPort());
|
||||
if(this.socket != null) {
|
||||
try {
|
||||
socket.send(packet);
|
||||
} catch (IOException e) {
|
||||
log.error("send() - Could not send packet: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
socket.close();
|
||||
|
|
|
@ -10,31 +10,30 @@ public class JsonUtil {
|
|||
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
for(int i=0; i<input.length(); i++) {
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char ch = input.charAt(i);
|
||||
int chx = (int) ch;
|
||||
|
||||
// let's not put any nulls in our strings
|
||||
if(chx == 0) {
|
||||
if ((int) ch == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(ch == '\n') {
|
||||
if (ch == '\n') {
|
||||
output.append("\\n");
|
||||
} else if(ch == '\t') {
|
||||
} else if (ch == '\t') {
|
||||
output.append("\\t");
|
||||
} else if(ch == '\r') {
|
||||
} else if (ch == '\r') {
|
||||
output.append("\\r");
|
||||
} else if(ch == '\\') {
|
||||
} else if (ch == '\\') {
|
||||
output.append("\\\\");
|
||||
} else if(ch == '"') {
|
||||
} else if (ch == '"') {
|
||||
output.append("\\\"");
|
||||
} else if(ch == '\b') {
|
||||
} else if (ch == '\b') {
|
||||
output.append("\\b");
|
||||
} else if(ch == '\f') {
|
||||
} else if (ch == '\f') {
|
||||
output.append("\\f");
|
||||
} else if(chx > 127) {
|
||||
output.append(String.format("\\u%04x", chx));
|
||||
} else if ((int) ch > 127) {
|
||||
output.append(String.format("\\u%04x", (int) ch));
|
||||
} else {
|
||||
output.append(ch);
|
||||
}
|
||||
|
@ -50,41 +49,42 @@ public class JsonUtil {
|
|||
|
||||
int i = 0;
|
||||
while (i < input.length()) {
|
||||
char delimiter = input.charAt(i); i++; // consume letter or backslash
|
||||
char delimiter = input.charAt(i);
|
||||
i++; // consume letter or backslash
|
||||
|
||||
if(delimiter == '\\' && i < input.length()) {
|
||||
if (delimiter == '\\' && i < input.length()) {
|
||||
|
||||
// consume first after backslash
|
||||
char ch = input.charAt(i); i++;
|
||||
char ch = input.charAt(i);
|
||||
i++;
|
||||
|
||||
if(ch == '\\' || ch == '/' || ch == '"' || ch == '\'') {
|
||||
if (ch == '\\' || ch == '/' || ch == '"' || ch == '\'') {
|
||||
builder.append(ch);
|
||||
}
|
||||
else if(ch == 'n') builder.append('\n');
|
||||
else if(ch == 'r') builder.append('\r');
|
||||
else if(ch == 't') builder.append('\t');
|
||||
else if(ch == 'b') builder.append('\b');
|
||||
else if(ch == 'f') builder.append('\f');
|
||||
else if(ch == 'u') {
|
||||
} else if (ch == 'n') builder.append('\n');
|
||||
else if (ch == 'r') builder.append('\r');
|
||||
else if (ch == 't') builder.append('\t');
|
||||
else if (ch == 'b') builder.append('\b');
|
||||
else if (ch == 'f') builder.append('\f');
|
||||
else if (ch == 'u') {
|
||||
|
||||
StringBuilder hex = new StringBuilder();
|
||||
|
||||
// expect 4 digits
|
||||
if (i+4 > input.length()) {
|
||||
if (i + 4 > input.length()) {
|
||||
throw new RuntimeException("Not enough unicode digits! ");
|
||||
}
|
||||
for (char x : input.substring(i, i + 4).toCharArray()) {
|
||||
if(!Character.isLetterOrDigit(x)) {
|
||||
if (!Character.isLetterOrDigit(x)) {
|
||||
throw new RuntimeException("Bad character in unicode escape.");
|
||||
}
|
||||
hex.append(Character.toLowerCase(x));
|
||||
}
|
||||
i+=4; // consume those four digits.
|
||||
i += 4; // consume those four digits.
|
||||
|
||||
int code = Integer.parseInt(hex.toString(), 16);
|
||||
builder.append((char) code);
|
||||
} else {
|
||||
throw new RuntimeException("Illegal escape sequence: \\"+ch);
|
||||
throw new RuntimeException("Illegal escape sequence: \\" + ch);
|
||||
}
|
||||
} else { // it's not a backslash, or it's the last character.
|
||||
builder.append(delimiter);
|
||||
|
|
Loading…
Reference in a new issue