Produced by Araxis Merge on 5/25/2018 9:21:42 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\AraxisMergeCompare\Pri_un\ZIP\DSM-cif\Direct Implementation\java\dns\src\main\java\org\nhindirect\dns\service | SimpleServiceRunner.java | Tue May 22 13:40:36 2018 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Direct Implementation\java\dns\src\main\java\org\nhindirect\dns\service | SimpleServiceRunner.java | Wed May 23 18:00:35 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 496 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /* | |
| 2 | Copyright (c) 2010, Direct Pr oject | |
| 3 | All right s reserved . | |
| 4 | ||
| 5 | Authors: | |
| 6 | Greg M eyer gm2552@cer ner.com | |
| 7 | ||
| 8 | Redistribu tion and u se in sour ce and bin ary forms, with or w ithout mod ification, are permi tted provi ded that t he followi ng conditi ons are me t: | |
| 9 | ||
| 10 | Redistribu tions of s ource code must reta in the abo ve copyrig ht notice, this list of condit ions and t he followi ng disclai mer. | |
| 11 | Redistribu tions in b inary form must repr oduce the above copy right noti ce, this l ist of con ditions an d the foll owing disc laimer in the docume ntation an d/or other materials provided with the d istributio n. | |
| 12 | Neither th e name of The Direct Project ( directproj ect.org) n or the nam es of its contributo rs may be used to en dorse or p romote pro ducts deri ved from t his softwa re without specific prior writ ten permis sion. | |
| 13 | THIS SOFTW ARE IS PRO VIDED BY T HE COPYRIG HT HOLDERS AND CONTR IBUTORS "A S IS" AND ANY EXPRES S OR IMPLI ED WARRANT IES, INCLU DING, BUT NOT LIMITE D TO, THE IMPLIED WA RRANTIES O F MERCHANT ABILITY AN D FITNESS FOR A PART ICULAR PUR POSE ARE D ISCLAIMED. IN NO EVE NT SHALL T HE COPYRIG HT HOLDER OR CONTRIB UTORS BE L IABLE FOR ANY DIRECT , INDIRECT , INCIDENT AL, SPECIA L, EXEMPLA RY, OR CON SEQUENTIAL DAMAGES ( INCLUDING, BUT NOT L IMITED TO, PROCUREME NT OF SUBS TITUTE GOO DS OR SERV ICES; LOSS OF USE, D ATA, OR PR OFITS; OR BUSINESS I NTERRUPTIO N) HOWEVER CAUSED AN D ON ANY T HEORY OF L IABILITY, WHETHER IN CONTRACT, STRICT LI ABILITY, O R TORT (IN CLUDING NE GLIGENCE O R OTHERWIS E) ARISING IN ANY WA Y OUT OF T HE USE OF THIS SOFTW ARE, EVEN IF ADVISED OF THE PO SSIBILITY OF SUCH DA MAGE. | |
| 14 | */ | |
| 15 | ||
| 16 | package or g.nhindire ct.dns.ser vice; | |
| 17 | ||
| 18 | import jav a.io.Buffe redReader; | |
| 19 | import jav a.io.Input StreamRead er; | |
| 20 | import jav a.net.Inet 4Address; | |
| 21 | import jav a.net.URL; | |
| 22 | import jav a.security .Security; | |
| 23 | ||
| 24 | import org .apache.co mmons.logg ing.Log; | |
| 25 | import org .apache.co mmons.logg ing.LogFac tory; | |
| 26 | import org .nhindirec t.dns.DNSE xception; | |
| 27 | import org .nhindirec t.dns.DNSS erverSetti ngs; | |
| 28 | ||
| 29 | ||
| 30 | /** | |
| 31 | * Simple command li ne based a pplication that laun ches the D NS server. Use the -help runt ime parame ter | |
| 32 | * to see usage. | |
| 33 | * @author Greg Meye r | |
| 34 | * @since 1.0 | |
| 35 | */ | |
| 36 | public cla ss SimpleS erviceRunn er | |
| 37 | { | |
| 38 | pr ivate stat ic final L og LOGGER = LogFacto ry.getFact ory().getI nstance(Si mpleServic eRunner.cl ass); | |
| 39 | ||
| 40 | pr ivate stat ic final S tring MODE _STANDALON E = "STAND ALONE"; | |
| 41 | pr ivate stat ic final S tring MODE _SERVER = "SERVER"; | |
| 42 | ||
| 43 | pr ivate stat ic int por t; | |
| 44 | pr ivate stat ic String bind; | |
| 45 | pr ivate stat ic URL ser vURL; | |
| 46 | pr ivate stat ic String mode; | |
| 47 | ||
| 48 | st atic | |
| 49 | { | |
| 50 | Secu rity.addPr ovider(new org.bounc ycastle.jc e.provider .BouncyCas tleProvide r()); | |
| 51 | ||
| 52 | port = PORT ; | |
| 53 | bind = "0.0.0. 0"; | |
| 54 | mode = MODE_ST ANDALONE; | |
| 55 | ||
| 56 | try | |
| 57 | { | |
| 58 | servUR L = new UR L("http:// localhost: 8080/confi g-service/ Configurat ionService "); | |
| 59 | } | |
| 60 | catc h (Excepti on e) {/* no-op */} | |
| 61 | } | |
| 62 | ||
| 63 | /* * | |
| 64 | * Main entr y point in to the app lication. | |
| 65 | * @param ar gv Command line argu ments. | |
| 66 | * / | |
| 67 | pu blic stati c void mai n(String[] argv) | |
| 68 | { | |
| 69 | ||
| 70 | // C heck param eters | |
| 71 | fo r (int i = 0; i < ar gv.length; i++) | |
| 72 | { | |
| 73 | String a rg = argv[ i]; | |
| 74 | ||
| 75 | // Optio ns | |
| 76 | if (!arg .startsWit h("-")) | |
| 77 | { | |
| 78 | Syst em.err.pri ntln("Erro r: Unexpec ted argume nt [" + ar g + "]\n") ; | |
| 79 | prin tUsage(); | |
| 80 | Syst em.exit(-1 ); | |
| 81 | } | |
| 82 | else if (arg.equal sIgnoreCas e("-p")) | |
| 83 | { | |
| 84 | if ( i == argv. length - 1 || argv[i + 1].star tsWith("-" )) | |
| 85 | { | |
| 86 | System.err .println(" Error: Mis sing port. "); | |
| 87 | System.exi t(-1); | |
| 88 | } | |
| 89 | ||
| 90 | port = Integer .parseInt( argv[++i]) ; | |
| 91 | ||
| 92 | } | |
| 93 | else if (arg.equal s("-b")) | |
| 94 | { | |
| 95 | if ( i == argv. length - 1 || argv[i + 1].star tsWith("-" )) | |
| 96 | { | |
| 97 | System.err .println(" Error: Mis sing bind IP address ."); | |
| 98 | System.exi t(-1); | |
| 99 | } | |
| 100 | bind = argv[++ i]; | |
| 101 | ||
| 102 | // v alidate it s a valid IP address es | |
| 103 | Stri ng checkIP = ""; | |
| 104 | try | |
| 105 | { | |
| 106 | String [] ips = b ind.split( ","); | |
| 107 | for (S tring ip : ips) | |
| 108 | { | |
| 109 | checkIP = ip; | |
| 110 | Inet4Add ress.getBy Name(check IP); | |
| 111 | } | |
| 112 | } | |
| 113 | catc h(Exceptio n e) | |
| 114 | { | |
| 115 | System .err.print ln("Error in bind IP address " + checkIP + " : " + e.getMess age()); | |
| 116 | System.exi t(-1); | |
| 117 | } | |
| 118 | } | |
| 119 | else if (arg.equal s("-u")) | |
| 120 | { | |
| 121 | if ( i == argv. length - 1 || argv[i + 1].star tsWith("-" )) | |
| 122 | { | |
| 123 | System.err .println(" Error: Mis sing servi ce URL"); | |
| 124 | System.exi t(-1); | |
| 125 | } | |
| 126 | Stri ng url = a rgv[++i]; | |
| 127 | try | |
| 128 | { | |
| 129 | servUR L = new UR L(url); | |
| 130 | } | |
| 131 | catc h (Excepti on e) | |
| 132 | { | |
| 133 | System .err.print ln("Error in service URL param eter: " + e.getMessa ge()); | |
| 134 | System.exi t(-1); | |
| 135 | } | |
| 136 | } | |
| 137 | else if (arg.equal s("-m")) | |
| 138 | { | |
| 139 | if ( i == argv. length - 1 || argv[i + 1].star tsWith("-" )) | |
| 140 | { | |
| 141 | System.err .println(" Error: Mis sing mode" ); | |
| 142 | System.exi t(-1); | |
| 143 | } | |
| 144 | mode = argv[++ i]; | |
| 145 | if ( !mode.equa lsIgnoreCa se(MODE_ST ANDALONE) && !mode.e qualsIgnor eCase(MODE _SERVER)) | |
| 146 | { | |
| 147 | System .err.print ln("Unknow n mode: " + mode); | |
| 148 | System .exit(-1); | |
| 149 | ||
| 150 | } | |
| 151 | } | |
| 152 | else if (arg.equal s("-help") ) | |
| 153 | { | |
| 154 | prin tUsage(); | |
| 155 | Syst em.exit(-1 ); | |
| 156 | } | |
| 157 | else | |
| 158 | { | |
| 159 | Syst em.err.pri ntln("Erro r: Unknown argument " + arg + "\n"); | |
| 160 | prin tUsage(); | |
| 161 | Syst em.exit(-1 ); | |
| 162 | } | |
| 163 | } | |
| 164 | ||
| 165 | st artAndRun( ); | |
| 166 | ||
| 167 | if (mode.equ alsIgnoreC ase(MODE_S TANDALONE) ) | |
| 168 | Syst em.exit(0) ; | |
| 169 | ||
| 170 | } | |
| 171 | ||
| 172 | /* | |
| 173 | * Creates, intializes , and runs the serve r. | |
| 174 | * / | |
| 175 | pr ivate stat ic void st artAndRun( ) | |
| 176 | { | |
| 177 | Stri ngBuffer b uffer = ne w StringBu ffer("Star ting DNS s erver. Se ttings:"); | |
| 178 | buff er.append( "\r\n\tBin d Addresse s: ").appe nd(bind); | |
| 179 | buff er.append( "\r\n\tLis ten Port: ").append( port); | |
| 180 | buff er.append( "\r\n\tSer vice URL: ").append( servURL.to String()); | |
| 181 | LOGG ER.info(bu ffer.toStr ing() + "\ n"); | |
| 182 | ||
| 183 | ||
| 184 | DNSS erverServi ce server = null; | |
| 185 | try | |
| 186 | { | |
| 187 | DNSSer verSetting s settings = new DNS ServerSett ings(); | |
| 188 | settin gs.setPort (port); | |
| 189 | settin gs.setBind Address(bi nd); | |
| 190 | ||
| 191 | server = new DNS ServerServ ice(servUR L, setting s); | |
| 192 | } | |
| 193 | catc h (DNSExce ption e) | |
| 194 | { | |
| 195 | LOGGER .error("Se rver faile d to start : " + e.ge tMessage() , e); | |
| 196 | return ; | |
| 197 | } | |
| 198 | ||
| 199 | if ( mode.equal sIgnoreCas e(MODE_STA NDALONE)) | |
| 200 | { | |
| 201 | LOGGER .info("\r\ nServer ru nning.... Press Ent er or Retu rn to stop ."); | |
| 202 | ||
| 203 | InputS treamReade r input = new InputS treamReade r(System.i n); | |
| 204 | Buffer edReader r eader = ne w Buffered Reader(inp ut); | |
| 205 | ||
| 206 | try | |
| 207 | { | |
| 208 | reader.r eadLine(); | |
| 209 | ||
| 210 | LOGGER.i nfo("Shutt ing down s erver. Wa it 5 secon ds for cle anup."); | |
| 211 | ||
| 212 | server.s topService (); | |
| 213 | ||
| 214 | Thread.s leep(5000) ; | |
| 215 | ||
| 216 | LOGGER.i nfo("Serve r stopped" ); | |
| 217 | } | |
| 218 | catch (Exception e) | |
| 219 | { | |
| 220 | ||
| 221 | } | |
| 222 | } | |
| 223 | else | |
| 224 | LOGGER .info("\r\ nServer ru nning."); | |
| 225 | } | |
| 226 | ||
| 227 | /* | |
| 228 | * Prints th e command line usage . | |
| 229 | * / | |
| 230 | privat e static v oid printU sage() | |
| 231 | { | |
| 232 | St ringBuffer use = new StringBuf fer(); | |
| 233 | us e.append(" Usage:\n") ; | |
| 234 | us e.append(" java Simpl eDNSServic eRunner (o ptions)... \n\n"); | |
| 235 | us e.append(" options:\n "); | |
| 236 | us e.append(" -p port IP lis tener port .\n"); | |
| 237 | us e.append(" Defa ult: 53\n\ n"); | |
| 238 | us e.append(" -b bind Comma limited li st of IP a ddresses t o bind to. \n"); | |
| 239 | us e.append(" Defa ult: 0.0.0 .0 (All IP addresses on local machine)\n \n"); | |
| 240 | us e.append(" -u URL URL of DNS confi guration s ervice.\n" ); | |
| 241 | us e.append(" Defa ult: http: //localhos t:8080/con fig-servic e/Configur ationServi ce\n\n"); | |
| 242 | us e.append(" -m mode Run mo de: STANDA LONE or SE RVER.\n"); | |
| 243 | us e.append(" Defa ult: STAND ALONE\n\n" ); | |
| 244 | ||
| 245 | ||
| 246 | Sy stem.err.p rintln(use ); | |
| 247 | } | |
| 248 | ||
| 249 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.