ability to choose external router in the wizard

dbus-notify
Zlatin Balevsky 2022-03-10 04:04:55 +00:00
parent d1ed888335
commit ff2274d51a
No known key found for this signature in database
GPG Key ID: A72832072D525E41
4 changed files with 86 additions and 18 deletions

View File

@ -68,7 +68,7 @@ MAX_RELIABILITY=Max Reliability
# Wizard last step
WIZARD_COMPLETE=The wizard is complete. Please press "Finish" to launch MuWire.
LAUNCH_EMBEDDED_ROUTER=MuWire will launch an embedded I2P router. This can take a few minutes.
LAUNCH_EMBEDDED_ROUTER=If you chose to use an embedded I2P router, MuWire may take a few minutes to load.
### Main window strings

View File

@ -92,7 +92,6 @@ class Ready extends AbstractLifecycleHandler {
File i2pPropsFile = new File(home, "i2p.properties")
i2pPropsFile.withPrintWriter { i2pProps.store(it, "") }
props.embeddedRouter = embeddedRouterAvailable
props.updateType = System.getProperty("updateType","jar")
props.disableUpdates = Boolean.parseBoolean(System.getProperty("disableUpdates", "false"))

View File

@ -9,6 +9,7 @@ import com.muwire.core.MuWireSettings
class EmbeddedRouterStep extends WizardStep {
boolean embeddedRouter
def udpPortField
def tcpPortField
@ -17,34 +18,82 @@ class EmbeddedRouterStep extends WizardStep {
def inBwField
def outBwField
// if the user chooses external...
def addressField
def portField
def builder
public EmbeddedRouterStep(WizardDefaults defaults) {
super("router", defaults)
}
@Override
protected void buildUI(FactoryBuilderSupport builder, def nextAction) {
this.builder = builder
builder.panel(constraints : getConstraint()) {
gridBagLayout()
panel(border : titledBorder(title : trans("PORT_SETTINGS"), border : etchedBorder(), titlePosition : TitledBorder.TOP,
constraints : gbc(gridx: 0, gridy : 0, fill : GridBagConstraints.HORIZONTAL, weightx: 100))) {
gridBagLayout()
label(text : trans("TCP_PORT"), constraints : gbc(gridx :0, gridy: 0, anchor : GridBagConstraints.LINE_START, weightx : 100))
tcpPortField = textField(text : String.valueOf(defaults.i2npTcpPort), columns : 4, constraints : gbc(gridx:1, gridy:0, anchor : GridBagConstraints.LINE_END))
label(text : trans("UDP_PORT"), constraints : gbc(gridx :0, gridy: 1, anchor : GridBagConstraints.LINE_START, weightx : 100))
udpPortField = textField(text : String.valueOf(defaults.i2npUdpPort), columns : 4, constraints : gbc(gridx:1, gridy:1, anchor : GridBagConstraints.LINE_END))
label(text : trans("USE_UPNP"), constraints: gbc(gridx: 0, gridy: 2, anchor: GridBagConstraints.LINE_START, weightx: 100))
useUPNPCheckbox = checkBox(selected: defaults.useUPNP, constraints: gbc(gridx: 1, gridy: 2, anchor: GridBagConstraints.LINE_END))
panel(border: titledBorder(title: trans("OPTIONS_ROUTER_TYPE"), border: etchedBorder(), titlePosition: TitledBorder.TOP,
constraints: gbc(gridx: 0, gridy: 0, fill: GridBagConstraints.HORIZONTAL, weightx: 100))) {
buttonGroup(id: "routerType")
radioButton(text : trans("OPTIONS_EMBEDDED"), toolTipText: trans("TOOLTIP_OPTIONS_EMBEDDED"),
selected: bind {defaults.embeddedRouter}, buttonGroup: routerType, actionPerformed : switchToEmbedded)
radioButton(text : trans("OPTIONS_EXTERNAL"), toolTipText: trans("TOOLTIP_OPTIONS_EXTERNAL"),
selected: bind {!defaults.embeddedRouter}, buttonGroup: routerType, actionPerformed : switchToExternal)
}
panel( border : titledBorder(title : trans("BANDWIDTH_SETTINGS"), border : etchedBorder(), titlePosition : TitledBorder.TOP),
constraints : gbc(gridx : 0, gridy : 1, fill : GridBagConstraints.HORIZONTAL, weightx : 100)) {
gridBagLayout()
label(text : trans("INBOUND_BANDWIDTH"), constraints : gbc(gridx: 0, gridy : 0, anchor : GridBagConstraints.LINE_START, weightx : 100))
inBwField = textField(text : String.valueOf(defaults.inBw), columns : 3, constraints : gbc(gridx : 1, gridy : 0, anchor : GridBagConstraints.LINE_END))
label(text : trans("OUTBOUND_BANDWIDTH"), constraints : gbc(gridx: 0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx : 100))
outBwField = textField(text : String.valueOf(defaults.outBw), columns : 3, constraints : gbc(gridx : 1, gridy : 1, anchor : GridBagConstraints.LINE_END))
panel(id : "router-props", constraints: gbc(gridx: 0, gridy: 1, fill: GridBagConstraints.HORIZONTAL, weightx: 100)) {
cardLayout()
panel(constraints : "router-props-embedded") {
gridBagLayout()
panel(border: titledBorder(title: trans("PORT_SETTINGS"), border: etchedBorder(), titlePosition: TitledBorder.TOP,
constraints: gbc(gridx: 0, gridy: 0, fill: GridBagConstraints.HORIZONTAL, weightx: 100))) {
gridBagLayout()
label(text: trans("TCP_PORT"), constraints: gbc(gridx: 0, gridy: 0, anchor: GridBagConstraints.LINE_START, weightx: 100))
tcpPortField = textField(text: String.valueOf(defaults.i2npTcpPort), columns: 4, constraints: gbc(gridx: 1, gridy: 0, anchor: GridBagConstraints.LINE_END))
label(text: trans("UDP_PORT"), constraints: gbc(gridx: 0, gridy: 1, anchor: GridBagConstraints.LINE_START, weightx: 100))
udpPortField = textField(text: String.valueOf(defaults.i2npUdpPort), columns: 4, constraints: gbc(gridx: 1, gridy: 1, anchor: GridBagConstraints.LINE_END))
label(text: trans("USE_UPNP"), constraints: gbc(gridx: 0, gridy: 2, anchor: GridBagConstraints.LINE_START, weightx: 100))
useUPNPCheckbox = checkBox(selected: defaults.useUPNP, constraints: gbc(gridx: 1, gridy: 2, anchor: GridBagConstraints.LINE_END))
}
panel(border: titledBorder(title: trans("BANDWIDTH_SETTINGS"), border: etchedBorder(), titlePosition: TitledBorder.TOP),
constraints: gbc(gridx: 0, gridy: 1, fill: GridBagConstraints.HORIZONTAL, weightx: 100)) {
gridBagLayout()
label(text: trans("INBOUND_BANDWIDTH"), constraints: gbc(gridx: 0, gridy: 0, anchor: GridBagConstraints.LINE_START, weightx: 100))
inBwField = textField(text: String.valueOf(defaults.inBw), columns: 3, constraints: gbc(gridx: 1, gridy: 0, anchor: GridBagConstraints.LINE_END))
label(text: trans("OUTBOUND_BANDWIDTH"), constraints: gbc(gridx: 0, gridy: 1, anchor: GridBagConstraints.LINE_START, weightx: 100))
outBwField = textField(text: String.valueOf(defaults.outBw), columns: 3, constraints: gbc(gridx: 1, gridy: 1, anchor: GridBagConstraints.LINE_END))
}
}
panel(constraints: "router-props-external", border : titledBorder(title : trans("EXTERNAL_ROUTER_I2CP_SETTINGS"), border : etchedBorder(), titlePosition : TitledBorder.TOP,
constraints : gbc(gridx: 0, gridy : 0, fill : GridBagConstraints.HORIZONTAL, weightx: 100))) {
gridBagLayout()
label(text : trans("HOST"), constraints : gbc(gridx: 0, gridy : 0, anchor : GridBagConstraints.LINE_START, weightx : 100))
addressField = textField(text : defaults.i2cpHost, constraints : gbc(gridx:1, gridy:0, anchor: GridBagConstraints.LINE_END))
label(text : trans("PORT"), constraints : gbc(gridx: 0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx : 100))
portField = textField(text : String.valueOf(defaults.i2cpPort), constraints : gbc(gridx:1, gridy:1, anchor: GridBagConstraints.LINE_END))
}
}
panel (constraints : gbc(gridx: 0, gridy : 2, weighty: 100))
}
if (defaults.embeddedRouter)
switchToEmbedded.call()
else
switchToExternal.call()
}
def switchToEmbedded = {
embeddedRouter = true
def cardsPanel = builder.getVarialbe("router-props")
cardsPanel.getLayout().show(cardsPanel, "router-props-embedded")
}
def switchToExternal = {
embeddedRouter = false
def cardsPanel = builder.getVarialbe("router-props")
cardsPanel.getLayout().show(cardsPanel, "router-props-external")
}
@Override
@ -70,12 +119,28 @@ class EmbeddedRouterStep extends WizardStep {
} catch (NumberFormatException e) {
rv << trans("INVALID_BANDWIDTH")
}
try {
InetAddress.getAllByName(addressField.text)
} catch (UnknownHostException iox) {
rv << trans("INVALID_ADDRESS")
}
try {
int port = Integer.parseInt(portField.text)
if (port <= 0 && port > 0xFFFF)
rv << trans("INVALID_PORT")
} catch (NumberFormatException e) {
rv << trans("INVALID_PORT")
}
rv
}
@Override
protected void apply(MuWireSettings muSettings, Properties i2pSettings) {
i2pSettings['i2cp.tcp.host'] = addressField.text
i2pSettings['i2cp.tcp.port'] = portField.text
i2pSettings['i2np.ntcp.port'] = tcpPortField.text
i2pSettings['i2np.udp.port'] = udpPortField.text
@ -85,5 +150,7 @@ class EmbeddedRouterStep extends WizardStep {
muSettings.outBw = Integer.parseInt(outBwField.text)
muSettings.inBw = Integer.parseInt(inBwField.text)
muSettings.embeddedRouter = embeddedRouter
}
}

View File

@ -11,6 +11,7 @@ class WizardDefaults {
int inBw, outBw
int tunnelLength, tunnelQuantity
boolean useUPNP
boolean embeddedRouter
WizardDefaults() {
this(new Properties())
@ -35,6 +36,7 @@ class WizardDefaults {
tunnelQuantity = Integer.parseInt(props.getProperty("tunnelQuantity","4"))
useUPNP = Boolean.parseBoolean(props.getProperty("useUPNP", "true"))
embeddedRouter = Boolean.parseBoolean(props.getProperty("embeddedRouter", "true"))
}
private static String getDefaultPath(String pathName) {