Site DB (#27)

(an instance of Generic Database made by Hacker)

     This object holds a db of places from which players have connected (see `help $site_db').
     The site blacklist and the graylist live as well (see `help blacklist').



VERB SOURCE CODE:

find* _only _every*:
return ((caller == this) || caller_perms().wizard) ? pass(@args) | E_PERM;
.


add:
":add(player,site)";
if (!caller_perms().wizard)
    return E_PERM;
endif
who = args[1];
domain = args[2];
if (this:domain_literal(domain))
    "... just enter it...";
    l = this:find_exact(domain);
    if (l == $failed_match)
        this:insert(domain, {who});
    elseif (!(who in l))
        this:insert(domain, setadd(l, who));
    endif
else
    "...an actual domain name; add player to list for that domain...";
    "...then add domain itself to list for the next larger domain; repeat...";
    "...  Example:  domain == foo.bar.edu:  ";
    "...            enter #who  on foo.bar.edu list";
    "...            enter `foo' on bar.edu list";
    "...            enter `bar' on edu list";
    if (!(dot = index(domain, ".")))
        dot = length(domain) + 1;
        domain = tostr(domain, ".", this.domain);
    endif
    prev = who;
    while ($failed_match == (l = this:find_exact(domain)))
        this:insert(domain, {prev});
        if (dot)
            prev = domain[1..dot - 1];
            domain = domain[dot + 1..length(domain)];
        else
            return;
        endif
        dot = index(domain, ".");
    endwhile
    if (!(prev in l))
        this:insert(domain, {@l, prev});
    endif
    return;
endif
.


load:
":load([start]) -- reloads site_db with the connection places of all players.";
"This routine calls suspend() if it runs out of time.";
"WIZARDLY";
"...needs to be able to read .all_connect_places";
if (!$perm_utils:controls(caller_perms(), this))
    return E_PERM;
endif
plist = players();
if (!args)
    this:clearall();
elseif (i = args[1] in plist)
    plist[1..i - 1] = {};
else
    return E_INVARG;
endif
for p in (plist)
    if (valid(p) && (is_player(p) && (!$object_utils:isa(p, $guest))))
        "... player may be recycled or toaded during the suspend(),...";
        "... guests login from everywhere...";
        for c in (p.all_connect_places)
            this:add(p, c);
            if ($command_utils:running_out_of_time())
                player:tell("...", p);
                suspend(0);
            endif
        endfor
    endif
endfor
.


domain_literal:
":domain_literal(string)";
" => true iff string is a domain literal (i.e., numeric IP address).";
if (10 <= (len = length(hnum = strsub(args[1], ".", ""))))
    return tonum(hnum[1..9]) && tonum(hnum[6..len]);
else
    return tonum(hnum);
endif
"SLEAZY CODE ALERT";
"... what I wanted to do was return tonum(strsub(args[1],\".\",\"\"))";
"... but on a 32-bit machine, this has a 1 in 4294967296 chance of failing";
"... (e.g., on \"42.94.967.296\", though I'll grant this particular example";
"...  entails some very strange subnetting on net 42, to say the least).";
"... So we do something that is guaranteed to work so long as internet";
"... addresses stay under 32 bits --- a while yet...";
"";
"... As soon as we're sure match() is working, this will become a one-liner:";
return match(args[1], "[0-9]+%.[0-9]+%.[0-9]+%.[0-9]+");
.


init_for_core:
if (caller_perms().wizard)
    pass();
    this:clearall();
    this.domain = "localdomain";
endif
.



PROPERTY DATA:
      domain
      w
      u
      r
      a
      c
      ra
      1
      d
      co
      N
      g
      m
      o
      14
      12
      128.1
      140
      128.8
      19
      e
      ac
      l
      ca
      um
      cu
      B
      an
      cs
      p
      ap
      la
      128.11
      h
      13
      go
      pa
      x
      el
      128.14
      131
      128.148.33
      ne
      uh
      Ha
      128.2
      131.218.2
      s
      t
      car
      br
      nex
      net
      be
      ma
      Netc
      ACF
      128
      bel
      ge
      AX
      cas
      bl
      mat
      ps
      bellevue-ip1
      ell
      uc
      ums
      gl
      bellevue-ip2
      wa
      K
      Pr
      bellevue-ip4
      re
      ga
      bellevue-ip3
      math
      cs.
      na
      129
      143
      rac
      ch
      128.148.38
      147
      sa
      129.1
      ny
      du
      di
      acc
      xe
      da
      mi
      ph
      de
      mo
      cl
      no
      pu
      ri
      WI
      po
      col
      bo
      dec
      chi
      xer
      un
      128.148.38.1
      128.25
      tr
      nor
      tra
      f
      mu
      128.17
      pc
      ucs
      pro
      198
      pl
      nam
      cc
      gc
      ka
      128.255.3
      hu
      cc.
      ro
      geo
      v
      to
      141
      toe
      uo
      ad
      por
      sn
      Acce
      do
      pi
      ci
      134
      pla
      li
      pan
      snca
      par
      uhu
      hi
      chin
      i
      Colo
      port4
      or
      gr
      ba
      bu
      129.12
      143.44.1
      sas
      OI
      TA
      lo
      134.5
      har
      netcom.
      en
      128.22
      128.8.7
      134.1
      128.6
      129.2
      128.148
      134.11
      va
      ic
      lis
      bellevue-ip6
      ucs.
      al
      netcom1
      fl
      bi
      cla
      fli
      cn
      chu
      cas.
      er
      130
      TS
      st
      pho
      csd
      uw
      si
      128.171.4
      me
      bos
      lam
      15
      se
      cun
      cam
      j
      y
      ya
      198.1
      is
      it
      hm
      16
      Sta
      fo
      3
      141.215.4
      140.142.5
      ste
      128.5
      128.112.9
      129.8
      129.2.98.15
      140.142.56
      130.6
      130.1
      137
      128.8.70.1
      129.2.98.10
      198.13
      128.171
      131.2
      128.59
      166
      192
      192.2
      port1
      129.2.98.16
      ar
      mil
      192.23
      dis
      cha
      128.6.7
      sc
      wv
      192.1
      sim
      ui
      and
      dat
      datl
      141.215.6
      as
      mac
      ei
      ru
      sp
      stat
      us
      yo
      M2
      138
      128.20
      carl
      seq
      pic
      M252-10
      ux
      ct
      ein
      134.114
      M252-1
      M252-9
      umd
      mod
      stei
      129.2.98.13
      cunyv
      gc.
      uni
      M252-11
      PSY
      baS
      scs
      129.1.
      trans
      uio
      128.171.44
      on
      dar
      mar
      sau
      141.215.48.10
      cis
      192.100.81.12
      eng
      ucd
      199
      at
      can
      cant
      ac.
      mack
      log
      dk
      basI
      129.1.2
      UHC
      cr
      clar
      bio
      unc
      141.215.48.19
      gw
      128.223
      scsun2
      gen
      arl
      lamp
      132
      com
      ua
      ROd
      PC.
      CC.C
      in
      fr
      M252-12
      192.100.81.11
      165
      128.206
      ho
      s2
      192.100.81.10
      s20
      math.
      th
      mic
      142
      gu
      act
      wo
      sl
      Dia
      132.20
      sli
      gui
      128.12
      134.12
      fa
      aca
      dialu
      mich
      134.124.5
      134.114.6
      pm
      pm03
      pm01
      sil
      ucs.u
      ef
      129.2.9
      193
      netcom2
      pm035
      134.124.4
      129.7
      M252
      pm035-0
      ki
      pm012-1
      access.m
      mb
      bro
      cisc
      ade
      le
      134.124.50
      131.218
      131.211
      ser
      128.171.41
      uncc
      128.9
      nau
      cisco-ts2-
      cw
      geni
      M250
      mot
      M250-14
      hom
      rs
      rsl
      homer1
      rh
      bra
      gol
      homer0
      Mt
      db
      te
      cw-
      cisco-ts2-line1
      tro
      PORT-
      umslt
      disu
      wr
      PORT-00
      cisco-ts2
      PORT-01
      cisco-ts5
      134.124.43.8
      umslts1_1
      134.53.1
      137.2
      mac7
      138.2
      13.
      ke
      134.124.1
      homer2
      134.124.43.9
      gru
      tu
      unix
      cl.
      ms
      snc
      cisco-ts2-line7
      for
      mer
      198.7
      carlo
      MSU
      128.16
      198.6
      umslts1_2
      137.22
      192.100.81.13
      MR
      msp
      msp81-1
      ee
      vi
      ep
      166.82.1.
      gan
      166.82.14
      em
      ve
      man
      164
      pri
      M250-15
      net2
      129.72
      access.
      nort
      mon
      128.223.3
      UHCL
      mont
      ed
      andr
      192.10
      its
      sm
      smc
      cau
      cq
      net1
      pm00
      z
      ACN
      Carle
      166.82.145.1
      xen
      199.2
      199.2.1
      PORT-03
      loc
      kr
      192.20
      134.53.14.11
      net0
      128.15
      pm003
      lu
      luc
      lucky12
      UT
      UTK
      che
      chem.
      lat
      128.255
      UTKV
      192.21
      LIB
      blv
      129.10
      LIBMAC1
      ara
      aragorn17
      128.164.12
      LIBMAC2
      ld
      mac6
      sk
      199.2.4
      hol
      36
      141.215.68
      dialup.
      gw.
      ty
      dialup-
      blv-pm4
      skynet-21
      HS
      141.215.66
      HSS
      128.164
      199.1
      skynet-22
      stem
      131.1
      micr
      at0
      x2
      128.223.1
      atd
      stemmons1
      LIBMAC0
      W2
      wal
      W20-575-1
      W20-575-12
      128.169
      128.95
      nas
      skynet-20
      129.82
      port2
      192.232
      nord
      dialup-3
      nas1
      flie
      128.169.3
      als
      edu
      128.112.1
      140.142.7
      msp81
      W20-575-11
      dialup-3-1
      vax
      ind
      blv-pm5
      p2
      oit.u
      nas1-1
      nas1-3
      spa
      dialup-3-2
      dy
      p0
      Free
      tel
      p5
      pp
      128.112.16
      walib9-22
      128.112.15
      epa
      p4
      dialup-5
      xenon.C
      CS.N
      2
      128.169.36.7
      dialup-4
      HSSMAC1
      oa
      140.14
      atdialup1
      phoe
      holl
      hc
      p1
      net5
      hcc1330b
      x215
      net4
      M1
      stemmons0
      es
      p3
      M25
      max
      ti
      spo
      efn.o
      org
      mc
      dial0
      lucky15
      ucc
      blv-pm4-ip2
      M3
      M6
      130.13
      204.1
      dial01
      dl
      cs.u
      disc
      dial00
      ix
      phoen
      ko
      at0-6
      lucky11
      hcc1330c
      gold.
      int
      bin
      cc.b
      bran
      prim
      204.11
      jh
      hcc
      bos1
      128.112.169
      dluv
      sh
      sw
      bet
      192.7
      acs
      wor
      gat
      nas1-2
      serv
      198.3
      199.10
      Merc
      192.204
      atdialup2
      dyna
      dyni
      198.14
      dialup-3-23
      rem
      comp
      C-
      stemmons2
      remote1
      ip
      199.3
      remote2
      cp
      140.142.70
      dialup-2
      dialup-5-14
      umd.
      umd1
      prime.
      fre
      RD
      128.112
      128.204
      aragorn1
      su
      dynip1
      cra
      fe
      up
      aragorn2
      147.9
      mul
      lucky14
      ppc
      ppp
      cis.
      192.8
      rav
      ppp3
      ab
      ppp4
      ppp7
      ppp-
      ppp-m04
      chr
      ppp5
      tom
      ang
      ppp-m03
      af
      aps
      au
      am
      ppp-m03-1
      gene
      ix-
      wri
      bc
      big
      blu
      eri
      Fi
      ppp-m02
      lin
      worl
      glad
      flic
      ppp-m02-1
      ppp-m04-0
      red
      pm002
      hcc1330a
      ppp-m04-1
      ppp-m02-0
      PORT-02
      ix-l
      ppp31
      unixs
      pm035-
      198.68
      140.15
      gp
      REN
      umi
      lar
      slip1
      ppp-m03-0
      PORT-04
      woo
      cs1
      ppp33
      cs128
      ix-lv1
      cs12
      cs127
      tun
      cs128-1