Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

87
LINES

< > TinyBrain | #1010768 - EagleDNS for botcompany.de [works / requires root]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Uses 1308K of libraries. Click here for Pure Java version (6770L/46K).

!7

static double refreshEvery = 60;
static int smartBotTimeOut = 60*5;

sS zone = [[
botcompany.de. IN    SOA   ai1.lol.  info.ai1.lol.  (
                                        20091118     ; Serial
                                        5M     ; Refresh
                                        2M     ; Retry
                                        5M     ; Expiry
                                        5M )   ; Minimum
@                       IN      NS      ai1.lol.
@                       IN      NS      tinybrain.de.
@                       IN      A       69.10.46.185
*                       IN      A       69.10.46.185
@                       MX      10      mail1.domainssaubillig.de.
]];

sS zone2 = [[
ai1.space. IN    SOA   ai1.lol.  info.ai1.lol.  (
                                        20091118     ; Serial
                                        5M     ; Refresh
                                        2M     ; Retry
                                        5M     ; Expiry
                                        5M )   ; Minimum
@                       IN      NS      tinybrain.de.
@                       IN      NS      ai1.lol.
@                       IN      A       185.183.156.46
*                       IN      A       185.183.156.46
@                       MX      10      mail1.domainssaubillig.de. ; TODO
]];

lib 1008223 // dnsjava
lib 1010766 // EagleDNS
lib 1004911 // log4j

import se.unlogic.eagledns.EagleDNS;

static File zonesDir;
static EagleDNS eagleDNS;

p {
  tryToAcquirePort5000();
  
  S conf = loadSnippet(#1010767);
  zonesDir = programFile("zones");
  saveZones();
  
  conf = conf.replace(
    [[<Property name="zoneFileDirectory">zones</Property>]],
    [[<Property name="zoneFileDirectory">]] + f2s(zonesDir) + [[</Property>]]);
  File configFile = saveProgramTextFile("config.xml", conf);
  
  //eagleDNS = nuObject("se.unlogic.eagledns.EagleDNS", f2s(configFile));
  eagleDNS = new EagleDNS(f2s(configFile));
  bot("Eagle DNS.");
  doEvery_daemon(refreshEvery, f refresh);
}

answer {
  if "test" ret "OK";
  if "refresh" {
    refresh();
    ret "OK";
  }
}

static void refresh() {
  saveZones();
  eagleDNS.reloadZones();
}

sS makeZone {
  S z = rtrim(zone);
  S ip = smartBotIP();
  if (ip != null) {
    z += "\nsmartbot-direct \*smartBotTimeOut*/      IN      A       " + ip;
    z += "\nsmartbot        \*smartBotTimeOut*/      IN      A       " + ip;
  }
  ret z;
}

static void saveZones {
  saveTextFile(newFile(zonesDir, "botcompany.de"), makeZone());
  saveTextFile(newFile(zonesDir, "ai1.space"), zone2);
}

download  show line numbers  debug dex   

Travelled to 7 computer(s): bvpoyihotdib, cfunsshuasjs, gwrvuhgaqvyk, jtubtzbbkimh, mqqgnosmbjvj, ppjhyzlbdabe, tvejysmllsmz

No comments. add comment

Snippet ID: #1010768
Snippet name: EagleDNS for botcompany.de [works / requires root]
Eternal ID of this version: #1010768/32
Text MD5: 28df214d84b8f63194a7b3d7c9834358
Transpilation MD5: 4cbf8a1df972379b51b6e9f46ebfcad2
Author: stefan
Category: javax / dns
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-12 15:14:54
Source code size: 2670 bytes / 87 lines
Pitched / IR pitched: No / No
Views / Downloads: 109 / 361
Version history: 31 change(s)
Referenced in: [show]