use of com.github.jh3nd3rs0n.jargyle.server.LogAction in project jargyle by jh3nd3rs0n.
the class Socks5UdpFirewallRule method toString.
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("firewallRuleAction=");
builder.append(this.getFirewallRuleAction());
if (this.clientAddressRange != null) {
builder.append(" clientAddressRange=");
builder.append(this.clientAddressRange);
}
if (this.method != null) {
builder.append(" method=");
builder.append(this.method);
}
if (this.user != null) {
builder.append(" user=");
builder.append(this.user);
}
if (this.peerAddressRange != null) {
builder.append(" peerAddressRange=");
builder.append(this.peerAddressRange);
}
LogAction logAction = this.getLogAction();
if (logAction != null) {
builder.append(" logAction=");
builder.append(logAction);
}
return builder.toString();
}
use of com.github.jh3nd3rs0n.jargyle.server.LogAction in project jargyle by jh3nd3rs0n.
the class ClientRoutingRule method toString.
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("routingRule=");
if (this.clientAddressRange != null) {
builder.append(" clientAddressRange=");
builder.append(this.clientAddressRange);
}
if (this.socksServerAddressRange != null) {
builder.append(" socksServerAddressRange=");
builder.append(this.socksServerAddressRange);
}
List<String> routeIds = this.getRouteIds();
if (routeIds.size() > 0) {
for (String routeId : routeIds) {
builder.append(" routeId=");
builder.append(routeId);
}
}
SelectionStrategy routeIdSelectionStrategy = this.getRouteIdSelectionStrategy();
if (routeIdSelectionStrategy != null) {
builder.append(" routeIdSelectionStrategy=");
builder.append(routeIdSelectionStrategy);
}
LogAction logAction = this.getLogAction();
if (logAction != null) {
builder.append(" logAction=");
builder.append(logAction);
}
return builder.toString();
}
use of com.github.jh3nd3rs0n.jargyle.server.LogAction in project jargyle by jh3nd3rs0n.
the class ClientRoutingRule method applyTo.
@Override
public void applyTo(final Rule.Context context) {
String routeId = this.getRouteIdSelector().select();
if (routeId == null) {
return;
}
Context cntxt = (Context) context;
Routes routes = cntxt.getRoutes();
Route route = routes.get(routeId);
if (route == null) {
return;
}
cntxt.setRoute(route);
LogAction logAction = this.getLogAction();
if (logAction == null) {
return;
}
String clientAddress = cntxt.getClientAddress();
logAction.invoke(String.format("Client route '%s' for %s is selected from the following " + "routing rule and context: %s, %s", routeId, clientAddress, this, context));
}
use of com.github.jh3nd3rs0n.jargyle.server.LogAction in project jargyle by jh3nd3rs0n.
the class Socks5ReplyFirewallRule method applyTo.
@Override
public void applyTo(final Rule.Context context) {
FirewallRuleAction firewallRuleAction = this.getFirewallRuleAction();
Context cntxt = (Context) context;
cntxt.setFirewallRuleAction(firewallRuleAction);
LogAction logAction = this.getLogAction();
if (logAction == null) {
return;
}
String clientAddress = cntxt.getClientAddress();
MethodSubnegotiationResults methSubnegotiationResults = cntxt.getMethodSubnegotiationResults();
String user = methSubnegotiationResults.getUser();
String possibleUser = (user != null) ? String.format(" (%s)", user) : "";
if (firewallRuleAction.equals(FirewallRuleAction.ALLOW)) {
logAction.invoke(String.format("SOCKS5 reply to %s%s is allowed based on the following " + "firewall rule and context: %s, %s", clientAddress, possibleUser, this, context));
} else if (firewallRuleAction.equals(FirewallRuleAction.DENY)) {
logAction.invoke(String.format("SOCKS5 reply to %s%s is denied based on the following " + "firewall rule and context: %s, %s", clientAddress, possibleUser, this, context));
}
}
use of com.github.jh3nd3rs0n.jargyle.server.LogAction in project jargyle by jh3nd3rs0n.
the class Socks5RequestFirewallRule method applyTo.
@Override
public void applyTo(final Rule.Context context) {
FirewallRuleAction firewallRuleAction = this.getFirewallRuleAction();
Context cntxt = (Context) context;
cntxt.setFirewallRuleAction(firewallRuleAction);
LogAction logAction = this.getLogAction();
if (logAction == null) {
return;
}
String clientAddress = cntxt.getClientAddress();
MethodSubnegotiationResults methSubnegotiationResults = cntxt.getMethodSubnegotiationResults();
String user = methSubnegotiationResults.getUser();
String possibleUser = (user != null) ? String.format(" (%s)", user) : "";
if (firewallRuleAction.equals(FirewallRuleAction.ALLOW)) {
logAction.invoke(String.format("SOCKS5 request from %s%s is allowed based on the " + "following firewall rule and context: %s, %s", clientAddress, possibleUser, this, context));
} else if (firewallRuleAction.equals(FirewallRuleAction.DENY)) {
logAction.invoke(String.format("SOCKS5 request from %s%s is denied based on the " + "following firewall rule and context: %s, %s", clientAddress, possibleUser, this, context));
}
}
Aggregations