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

76
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 (6980L/47K).

!7

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

sS zone = [[
botcompany.de. IN    SOA   ai1.space.  stefan\.reich\.maker\.of\.eye.gmail.com.  (
                                        20091118     ; Serial
                                        30M     ; Refresh
                                        2M      ; Retry
                                        30M     ; Expiry
                                        30M )   ; Minimum
@                       IN      NS      tinybrain.de.
@                       IN      NS      ai1.space.
@                       IN      A       69.10.46.185
butter                  IN      A       185.183.156.46
www                     IN      A       185.183.156.46
home                300 IN      A       2.203.147.169
*                       IN      A       69.10.46.185
@                       MX      10      mail1.domainssaubillig.de.
]];

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"), null /*zone2*/);
}

download  show line numbers  debug dex   

Travelled to 9 computer(s): bvpoyihotdib, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, mqqgnosmbjvj, ppjhyzlbdabe, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1010768
Snippet name: EagleDNS for botcompany.de [works / requires root]
Eternal ID of this version: #1010768/41
Text MD5: 4c653f789230c98940abb61359b3ca7e
Transpilation MD5: e8b0593c054baedc1573f5eecafcf23f
Author: stefan
Category: javax / dns
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-02 11:51:02
Source code size: 2225 bytes / 76 lines
Pitched / IR pitched: No / No
Views / Downloads: 211 / 610
Version history: 40 change(s)
Referenced in: [show]