mirror of
https://github.com/go-i2p/go-i2ptunnel.git
synced 2025-12-20 15:15:52 -05:00
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package ircserver
|
|
|
|
/** TODO: implement filters from Java I2P using IRC Filter from go-connfilter.
|
|
Java filters copied here:
|
|
|
|
// Server-side filtering logic
|
|
protected void handleConnection(Socket socket) {
|
|
// Transforms incoming connections
|
|
String dest = socket.getInetAddress().toString();
|
|
// Masks real destination with .i2p
|
|
dest = dest.replace(getRealHost(), getI2PHost());
|
|
}
|
|
|
|
// Command filtering
|
|
private String filterLine(String line) {
|
|
// Block administrative commands
|
|
if (line.startsWith("/ADMIN") ||
|
|
line.startsWith("/OPER") ||
|
|
line.startsWith("/DIE") ||
|
|
line.startsWith("/RESTART"))
|
|
return null;
|
|
|
|
// Replace real IPs with .i2p addresses
|
|
if (line.contains("@")) {
|
|
line = line.replaceAll("@[^\\s]+", "@" + getI2PHost());
|
|
}
|
|
|
|
// Filter WHOIS responses
|
|
if (line.startsWith("311 ")) {
|
|
// Mask user host information
|
|
return maskWhoisResponse(line);
|
|
}
|
|
|
|
return line;
|
|
}
|
|
|
|
// Host information masking
|
|
private String maskWhoisResponse(String line) {
|
|
// Replace real hostnames with .i2p
|
|
return line.replaceAll("\\s+[^\\s!]+@[^\\s]+", " unknown@" + getI2PHost());
|
|
}
|
|
|
|
// DCC command blocking
|
|
private void blockDCC(String line) {
|
|
if (line.toUpperCase().contains("DCC")) {
|
|
// Block all DCC attempts
|
|
throw new SecurityException("DCC not allowed");
|
|
}
|
|
}
|
|
*/
|