[613] | 1 | XMKPRD ;ISC-SF/GMB-DNS Interface ;07/11/2002 08:09
|
---|
| 2 | ;;8.0;MailMan;;Jun 28, 2002
|
---|
| 3 | NEXTIPF(XMSITE,XMIPT,XMIPLIST) ; Function returns next IP address to try.
|
---|
| 4 | ; IN:
|
---|
| 5 | ; XMSITE - .01 field of domain in file 4.2 (not a synonym)
|
---|
| 6 | ; XMIPT - List of IP addresses, separated by ",", already tried
|
---|
| 7 | ; XMIPLIST - (optional) List of IP addresses, separated by ",", to try
|
---|
| 8 | I '$D(XMIPLIST) D
|
---|
| 9 | . D SHOW(42260) ;Call DNS for IP Address list ...
|
---|
| 10 | . S XMIPLIST=$$IPADDR(XMSITE)
|
---|
| 11 | . D SHOW($S(XMIPLIST="":42261,1:42262),XMIPLIST) ;Returned: Nothing!/|1|
|
---|
| 12 | I XMIPLIST="" Q ""
|
---|
| 13 | I $G(XMIPT)="" Q $P(XMIPLIST,",")
|
---|
| 14 | N XMJ,XMIP
|
---|
| 15 | F XMJ=1:1:$L(XMIPT,",") D Q:XMIP=""!(","_XMIPT_","'[(","_XMIP_","))
|
---|
| 16 | . S XMIP=$P(XMIPT,",",XMJ)
|
---|
| 17 | . D NEXTIP(.XMIP,.XMIPLIST)
|
---|
| 18 | Q XMIP
|
---|
| 19 | IPADDR(XMSITE) ;
|
---|
| 20 | N XMIPARY,XMIP,XMIPSITE,XMI,XMIPREC,XMIPLIST
|
---|
| 21 | D MAIL^XLFNSLK(.XMIPARY,XMSITE)
|
---|
| 22 | S XMI=0
|
---|
| 23 | F S XMI=$O(XMIPARY(XMI)) Q:'XMI D
|
---|
| 24 | . S XMIPREC=XMIPARY(XMI)
|
---|
| 25 | . S XMIP=$P(XMIPREC,U,2)
|
---|
| 26 | . ;I XMIP'?1.N1"."1.N1"."1.N1".".E D Q
|
---|
| 27 | . I XMIP="" D Q
|
---|
| 28 | . . D SHOW(42260.1,XMIPREC) ;Ignore '|1|' - no IP address
|
---|
| 29 | . S XMIPSITE=$$UP^XLFSTR($P(XMIPREC,U,1))
|
---|
| 30 | . ; Accept whatever DNS returns, except for FORUM. We accept FORUM if
|
---|
| 31 | . ; we're trying to get to FORUM, but we don't want messages destined
|
---|
| 32 | . ; for another site to be routed through FORUM. If this is a non-VA
|
---|
| 33 | . ; site, then it's OK to route through FORUM.
|
---|
| 34 | . I ^XMB("NETNAME")[".VA.GOV",XMSITE'["FORUM.VA.GOV",XMIPSITE["FORUM.VA.GOV" D Q
|
---|
| 35 | . . D SHOW(42260.2,XMIPREC) ;Ignore '|1|' - that's a different site
|
---|
| 36 | . ;I '$$SAMESITE(XMIPSITE,XMSITE) D Q
|
---|
| 37 | . ;. D SHOW(42260.2,XMIPREC) ;Ignore '|1|' - that's a different site
|
---|
| 38 | . I ","_$G(XMIPLIST)_","[(","_XMIP_",") D Q
|
---|
| 39 | . . D SHOW(42260.3,XMIPREC) ;Ignore '|1|' - already have that IP address
|
---|
| 40 | . D SHOW(42260.4,XMIPREC) ;Accept '|1|'
|
---|
| 41 | . I $G(XMIPLIST)="" S XMIPLIST=XMIP Q
|
---|
| 42 | . S XMIPLIST=XMIPLIST_","_XMIP
|
---|
| 43 | Q $G(XMIPLIST)
|
---|
| 44 | SAMESITE(X,XMSITE) ;
|
---|
| 45 | N DIC,Y,D
|
---|
| 46 | I $E(X,$L(X))="." S X=$E(X,1,$L(X)-1)
|
---|
| 47 | S DIC="^DIC(4.2,",DIC(0)="FMXZ",D="B^C"
|
---|
| 48 | F D MIX^DIC1 Q:Y>0!(X'[".") S X=$P(X,".",2,99)
|
---|
| 49 | I Y,Y(0,0)=XMSITE Q 1
|
---|
| 50 | Q 0
|
---|
| 51 | SHOW(XMDIALOG,XM1) ;
|
---|
| 52 | I $D(ZTQUEUED)!'$G(XMC("PLAY")) Q
|
---|
| 53 | I +XMDIALOG=XMDIALOG W !,$$EZBLD^DIALOG(XMDIALOG,$G(XM1)) Q
|
---|
| 54 | W !,XMDIALOG
|
---|
| 55 | Q
|
---|
| 56 | NEXTIP(XMIP,XMIPLIST) ;
|
---|
| 57 | N XMI
|
---|
| 58 | F XMI=1:1:$L(XMIPLIST,",") Q:$P(XMIPLIST,",",XMI)=XMIP
|
---|
| 59 | I XMIP'=$P(XMIPLIST,",",XMI) S XMIP=$P(XMIPLIST,","),XMIPLIST=$P(XMIPLIST,",",2,99) Q
|
---|
| 60 | I XMI=1 S XMIPLIST=$P(XMIPLIST,",",2,99)
|
---|
| 61 | E I XMI=$L(XMIPLIST,",") S XMIPLIST=$P(XMIPLIST,",",1,XMI-1)
|
---|
| 62 | E S XMIPLIST=$P(XMIPLIST,",",1,XMI-1)_","_$P(XMIPLIST,",",XMI+1,99)
|
---|
| 63 | S XMIP=$P(XMIPLIST,","),XMIPLIST=$P(XMIPLIST,",",2,99)
|
---|
| 64 | Q
|
---|
| 65 | ; *** The following is not used ***
|
---|
| 66 | CONNECT(XMSITE,XMIP,XMPORT) ; Function tries to connect to site.
|
---|
| 67 | ; Returns the IP address if success; 0 if failure
|
---|
| 68 | ; XMSITE - Site name to connect to
|
---|
| 69 | ; XMIP - Site IP address to try first (optional). If none given,
|
---|
| 70 | ; or if attempt fails, DNS is called to retrieve address(es).
|
---|
| 71 | ; XMPORT - Port number to use (optional, default=25)
|
---|
| 72 | N XMIPLIST,XMOK
|
---|
| 73 | I '$G(XMPORT) S XMPORT=25
|
---|
| 74 | D SHOW("Connect to "_XMSITE_" on port "_XMPORT_$S($G(XMIP):", IP Address "_XMIP,1:""))
|
---|
| 75 | I $G(XMIP)="" D NEXTIPR(XMSITE,.XMIP,.XMIPLIST) Q:XMIP="" 0
|
---|
| 76 | S XMOK=0
|
---|
| 77 | F D TRYIP(XMIP,.XMOK) Q:XMOK D NEXTIPR(XMSITE,.XMIP,.XMIPLIST) Q:XMIP=""
|
---|
| 78 | Q:XMOK XMIP
|
---|
| 79 | D SHOW("Connect failed. Try again later.")
|
---|
| 80 | Q 0
|
---|
| 81 | NEXTIPR(XMSITE,XMIP,XMIPLIST) ; Routine returns next IP address to try
|
---|
| 82 | ; IN/OUT:
|
---|
| 83 | ; XMIP - in: Last IP address tried
|
---|
| 84 | ; out: Next IP address to try
|
---|
| 85 | ; XMIPLIST - in: (optional) List of IP addresses, separated by ",",
|
---|
| 86 | ; we haven't yet tried
|
---|
| 87 | ; out: Same, but with XMIP (out) removed
|
---|
| 88 | I '$D(XMIPLIST) D
|
---|
| 89 | . D SHOW(42260) ;Call DNS for IP Address list ...
|
---|
| 90 | . S XMIPLIST=$$IPADDR(XMSITE)
|
---|
| 91 | . D SHOW($S(XMIPLIST="":42261,1:42262),XMIPLIST) ;Returned: Nothing!/|1|
|
---|
| 92 | I XMIPLIST="" S XMIP="" Q
|
---|
| 93 | I $G(XMIP)="" S XMIP=$P(XMIPLIST,","),XMIPLIST=$P(XMIPLIST,",",2,99) Q
|
---|
| 94 | D NEXTIP(.XMIP,.XMIPLIST)
|
---|
| 95 | Q
|
---|
| 96 | TRYIP(XMIP,XMOK) ; Try the IP address, if it works, set XMOK=1
|
---|
| 97 | D SHOW("Trying "_XMIP)
|
---|
| 98 | D CALL^%ZISTCP(XMIP,XMPORT)
|
---|
| 99 | S XMOK='POP
|
---|
| 100 | I 'XMOK D SHOW("Attempt failed.")
|
---|
| 101 | Q
|
---|