~dr|z3d
@RN
@RN_
@StormyCloud
@T3s|4
@T3s|4_
@eyedeekay
@not_bob
@orignal
@postman
@zzz
%Liorar
+FreefallHeavens
+Over
+Xeha
+acetone
+bak83
+cumlord
+hk
+onon_
+poriori
+profetikla
+r00tobo_BNC
+uop23ip
+weko
An0nm0n
Arch
Danny
DeltaOreo
Irc2PGuest53061
Irc2PGuest57148
Irc2PGuest60340
Meow
Nausicaa
Onn4l7h
Onn4|7h
anon3
anu3
boonst
cancername
carried6590
mareki2pb
plap
shiver_
simprelay
solidx66
thetia
u5657
dr|z3d
got a code issue that's giving me grief, zzz. have you got a few minutes?
zzz
shoot
dr|z3d
ok, thanks. so I'm trying to set inbound/outbound.lengthVariance in snark, and it's being a real pita.
dr|z3d
I've got toggles for both, separate, click on/off, for a +0/1 variation when enabled.
dr|z3d
can't figure out how to set those values when save is applied the first time. currently I'm adding the values to the text input, on save, and then another save is required to activate them. works for "on", doesn't work for off.
zzz
they're checkboxes?
dr|z3d
yeah
dr|z3d
let me pull up the commit.. it's been tweaked since then, but you'll get a basic idea of what I'm doing (wrong).
zzz
check the POST data in inspector, but I belive browsers don't send the input field for unchecked boxes, so you have to assume unchecked if the field is not in the POST data
dr|z3d
yeah, I'm handling that ok I think. if the value is submitted, we're "on", otherwise off.
dr|z3d
the issue is, I think, more, how to force an immediate update of the i2cp values when save is hit for the first time.
dr|z3d
boolean enableVaryInboundHops = req.getParameter("varyInbound") != null;
dr|z3d
boolean enableVaryOutboundHops = req.getParameter("varyOutbound") != null;
zzz
well, you have to tell the router of course
zzz
are you doing that?
dr|z3d
yeah, this is where's I'm at with that:
dr|z3d
if (_util.enableVaryInboundHops() != enableVaryInboundHops) {
dr|z3d
_config.setProperty(PROP_VARY_INBOUND_HOPS, Boolean.toString(enableVaryInboundHops));
dr|z3d
if (enableVaryInboundHops) {addMessage(_t("Enabled +0/1 tunnel hop randomization on Inbound tunnels"));}
dr|z3d
else {addMessage(_t("Disabled tunnel hop randomization on Inbound tunnels"));}
dr|z3d
_util.setEnableVaryInboundHops(enableVaryInboundHops);
dr|z3d
changed = true;
dr|z3d
}
dr|z3d
if (_util.enableVaryOutboundHops() != enableVaryOutboundHops) {
dr|z3d
_config.setProperty(PROP_VARY_OUTBOUND_HOPS, Boolean.toString(enableVaryOutboundHops));
dr|z3d
if (enableVaryInboundHops) {addMessage(_t("Enabled +0/1 tunnel hop randomization on Outbound tunnels"));}
dr|z3d
else {addMessage(_t("Disabled tunnel hop randomization on Outbound tunnels"));}
dr|z3d
_util.setEnableVaryOutboundHops(enableVaryOutboundHops);
dr|z3d
changed = true;
dr|z3d
}
dr|z3d
and then in util:
dr|z3d
@SuppressWarnings({"unchecked", "rawtypes"})
dr|z3d
public void setI2CPConfig(String i2cpHost, int i2cpPort, Map opts) {
dr|z3d
if (i2cpHost != null) {_i2cpHost = i2cpHost;}
dr|z3d
if (i2cpPort > 0) {_i2cpPort = i2cpPort;}
dr|z3d
if (getVaryInboundHops()) {_opts.put("inbound.tunnelVariance", "1");}
dr|z3d
else {_opts.remove("inbound.tunnelVariance");}
dr|z3d
if (getVaryOutboundHops()) {_opts.put("outbound.tunnelVariance", "1");}
dr|z3d
else {_opts.remove("outbound.tunnelVariance");}
dr|z3d
if (opts != null) {
dr|z3d
synchronized(_opts) {
dr|z3d
// removed options...
dr|z3d
for (Iterator<String> iter = _opts.keySet().iterator(); iter.hasNext(); ) {
dr|z3d
String k = iter.next();
dr|z3d
if (!HIDDEN_I2CP_OPTS.contains(k) && !opts.containsKey(k)) {iter.remove();}
dr|z3d
}
dr|z3d
_opts.putAll(opts);
dr|z3d
}
dr|z3d
}
dr|z3d
// this updates the session options and tells the router
dr|z3d
setMaxUpBW(_maxUpBW);
dr|z3d
if (_manager != null) {
dr|z3d
I2PSession sess = _manager.getSession();
dr|z3d
if (sess != null) {
dr|z3d
Properties newProps = new Properties();
dr|z3d
synchronized(_opts) {newProps.putAll(_opts);}
dr|z3d
sess.updateOptions(newProps);
dr|z3d
}
dr|z3d
}
dr|z3d
}
dr|z3d
also in util:
dr|z3d
public boolean getVaryInboundHops() {return _varyInboundHops;}
dr|z3d
public boolean getVaryOutboundHops() {return _varyOutboundHops;}
dr|z3d
public void setVaryInboundHops(boolean yes) {
dr|z3d
Properties opts = _context.getProperties();
dr|z3d
_varyInboundHops = yes;
dr|z3d
if (_varyInboundHops) {opts.setProperty("inbound.lengthVariance", "1");}
dr|z3d
else {opts.setProperty("inbound.lengthVariance", "0");}
dr|z3d
}
dr|z3d
public void setVaryOutboundHops(boolean yes) {
dr|z3d
Properties opts = _context.getProperties();
dr|z3d
_varyOutboundHops = yes;
dr|z3d
if (_varyOutboundHops) {opts.setProperty("outbound.lengthVariance", "1");}
dr|z3d
else {opts.setProperty("outbound.lengthVariance", "0");}
dr|z3d
}
zzz
the router side probably isn't going to recognize and deal with removed options, so set variances to "0" instead of opts.remove()
dr|z3d
ok, that makes sense, enable is kind of working, albeit with 2* save required, disable isn't.
zzz
it's like that because there could be a zillion other options set initially, you don't know what those were and don't want those auto-removed when you do an updateOptions()
zzz
don't know if that's documented anywhere though
zzz
so once you add a variance, you can only turn it back off by setting to 0
dr|z3d
well, I suspect I'm going to be nuking any pre-existing variance configs, but I'm ok with that for now, +0/1 is probably the only sane value in snark.
dr|z3d
ok, thanks. that's good info.
dr|z3d
is there anything explicit that I need to be doing on save configs to ensure the new values get immediately applied?
dr|z3d
it's currently a 2*save thing, first time populates the i2cp text input with the values, second time saves those values.
zzz
can't think of any generic advice, you'll have to just go thru your code and figure out why
dr|z3d
ok, thanks. I'll keep introducing my head to the nearest wall until something works then :)
dr|z3d
I think I may have found something, maybe setting varyEnabled values too late in locked_updateConfig, after the i2cp options have been set. I'll let you know when I got it fixed. thanks again for the help.
dr|z3d
on a totally different issue, did you ever look at google-java-format?
zzz
we have our style guide, not interested in somebody else's
dr|z3d
sure, not asking because formatting per se.
dr|z3d
asking because it has an interesting feature to remove unused imports from class files, and when you run it the unused imports are off the charts.
zzz
not surprising
zzz
jrandom can get some of the blame but copypasta also a culprit. also sometimes things start out complex and then don't get cleaned up
dr|z3d
I just wonder whether a single pass with that tool is a "good idea" to remove the cruft.
zzz
knock yourself out
dr|z3d
no issue with compiling after the imports removed.
dr|z3d
oh, I'm probably going to do it, just thought you might be interested. I can give you a simple bash script to handle it all.
dr|z3d
#!/bin/sh
dr|z3d
if [ $# -ne 1 ]; then
dr|z3d
echo "Usage: $0 directory"
dr|z3d
exit 1
dr|z3d
fi
dr|z3d
directory=$1
dr|z3d
find "$directory" -name "*.java" -print0 | xargs -0 /usr/lib/jvm/java-22-openjdk-amd64/bin/java -jar ./google-java-format.jar --replace --fix-imports-only --skip-sorting-imports
dr|z3d
requires the .jar with dependencies version, I've pointed it at latest java, but it'll likely work with earlier versions (just not 8).
zzz
ok
dr|z3d
script takes a folder as argument.
dr|z3d
also, re geomap, this looks interesting: leafletjs.com
zzz
I made a plan for the big maps refactor and started on it. I got the js delta injection add/remove working.
zzz
but gosh animation is a CPU pig, bad on chrome, even worse on firefox
zzz
may have to rip it out or make it optional
snex
Isn’t it already optional as in you have to click the Map tab
zzz
thats where drz has it for now, I have it at the top of netdb summary page, don't know where it will end up