Skip to content

Commit 2371aa2

Browse files
committed
Setting to not stay running.
1 parent 6e43ab5 commit 2371aa2

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ Password:
2020
Record ID:
2121
Minutes: 30
2222
Last IP:
23+
Exit: false
2324
```
2425

25-
`User` and `Password` are your DnsMadeEasy credentials. You may optionally configure DnsMadeEasy to have a password per record, so you don't need to use your account password. `Record ID` identifies the record to update. `Minutes` is the number of minutes between IP checks. `Last IP` does not need to be set manually.
26+
`User` and `Password` are your DnsMadeEasy credentials. You may optionally configure DnsMadeEasy to have a password per record, so you don't need to use your account password. `Record ID` identifies the record to update. `Minutes` is the number of minutes between IP checks. `Last IP` does not need to be set manually. If `Exit` is true, the program does not stay running. It will check the IP and update if needed, then exit.
2627

2728
After saving the `config.txt` file, the DnsMadeEasy tool must be restarted. On Windows the tool runs in the background and only a single instance is allowed, so use Task Manager to end the task before starting it again.
2829

src/com/esotericsoftware/dnsmadeeasy/DnsMadeEasy.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,21 @@ public class DnsMadeEasy {
2424

2525
String user = "", pass = "", id = "", lastIP = "";
2626
int minutes = 30;
27+
boolean exit;
2728
final File configFile = new File(System.getProperty("user.home"), ".dnsmadeeasy/config.txt");
2829

2930
public DnsMadeEasy () throws IOException {
30-
loadConfig();
31-
3231
log("Started.", null);
32+
loadConfig();
3333
new Timer("Timer").schedule(new TimerTask() {
3434
public void run () {
3535
try {
36+
loadConfig();
3637
update(user, pass, id);
3738
} catch (IOException ex) {
38-
ex.printStackTrace();
39+
log("Error updating.", ex);
3940
}
41+
if (exit) System.exit(0);
4042
}
4143
}, 0, minutes * 60 * 1000);
4244
}
@@ -51,8 +53,8 @@ void update (String user, String pass, String id) throws IOException {
5153
}
5254
if (newIP.equals(lastIP)) return;
5355

54-
String result = http("http://cp.dnsmadeeasy.com/servlet/updateip?username=" + user + "&password=" + pass + "&id=" + id
55-
+ "&ip=" + newIP);
56+
String result = http(
57+
"http://cp.dnsmadeeasy.com/servlet/updateip?username=" + user + "&password=" + pass + "&id=" + id + "&ip=" + newIP);
5658
log(newIP + ", " + result, null);
5759
if (result.equals("success")) {
5860
lastIP = newIP;
@@ -78,7 +80,8 @@ void saveConfig () throws IOException {
7880
writer.write("Password: " + pass + "\r\n");
7981
writer.write("Record ID: " + id + "\r\n");
8082
writer.write("Minutes: " + minutes + "\r\n");
81-
writer.write("Last IP: " + lastIP);
83+
writer.write("Last IP: " + lastIP + "\r\n");
84+
writer.write("Exit: " + exit);
8285
writer.close();
8386
}
8487

@@ -91,6 +94,7 @@ void loadConfig () throws IOException {
9194
id = value(reader.readLine());
9295
minutes = Integer.parseInt(value(reader.readLine()));
9396
lastIP = value(reader.readLine());
97+
exit = Boolean.parseBoolean(value(reader.readLine()));
9498
} catch (Exception ex) {
9599
throw new RuntimeException("Error reading config file: " + configFile.getAbsolutePath(), ex);
96100
}

0 commit comments

Comments
 (0)