Ejemplo n.º 1
0
def fix(db, sess, src, srcname, destname, domain, password, msgid, cmdtext, is_local):
  dom, text = db.prepare("select domain, text from addresses where id=$1").first(src)
  if dom != db.FTN_domains["node"]:
    raise FTNFail("not our domain")
  print(text)
  link_id, addr_id, myaddr_id = ftnaccess.check_link(db, text, password, True)
  if myaddr_id is None:
    reply=["wrong password"]
  elif link_id is None:
    reply=["unknown link"]
  elif not is_local:
    reply=["request delivered not directly, please consider changing the password"]
  else:
    reply=[]
    for cmd in map(str.strip, cmdtext.upper().strip().split("\n")):
      if cmd.startswith("---"):
        break
      elif len(cmd)==0:
        continue
      elif cmd.startswith("%PING"):
        reply.append("NOP: "+cmd)
      elif cmd.startswith("%QUERY"):
        for area in ftnexport.get_node_subscriptions(db, text, domain):
          reply.append(area)
      elif cmd.startswith("%HELP"):
        reply.append("Use following command:")
        reply.append("  %QUERY          -- list of subscribed areas")
        reply.append("  %LIST           -- list of all areas")
        reply.append("  +areaname       -- subscribe, or:")
        reply.append("  areaname        -- subscribe")
        reply.append("  -areaname       -- unsubscribe")
        reply.append("        you can use ? to substitite any one character an area name")
        reply.append("        or * to substitude any number of any characters in area name")
        reply.append("        areaname must be UPPERCASE")
        reply.append("  %RESET area YYYY-MM-DD -- reset area to specified date")
        reply.append("")
      elif cmd.startswith("%LIST"):
        for area in ftnexport.get_all_targets(db, domain):
          reply.append(area)
      elif cmd.startswith("%AVAIL"):
        reply.append("Sorry not implemented: "+cmd)
      elif cmd.startswith("%PAUSE"):
        reply.append("Sorry not implemented: "+cmd)
      elif cmd.startswith("%RESET"):
        reply += reset(db, sess, text, domain, cmd[7:])
      elif cmd.startswith("-"):
        reply += unsubscribe(db, sess, text, domain, cmd[1:])
      elif cmd.startswith("+"):
        reply += subscribe(db, sess, text, domain, cmd[1:])
      elif cmd.startswith("%"):
        reply.append("Unknown command: "+cmd)
        print(cmd)
#        1/0
      else:
        reply+=subscribe(db, sess, text, domain, cmd)

  reply.append("")
  sess.send_message(ftnconfig.get_taddr(db, myaddr_id), destname+" Robot", ("node", text), srcname, msgid, "report", "\n".join(reply), sendmode="direct")
  print(reply)
Ejemplo n.º 2
0
#!/usr/local/bin/python3 -bb

import ftnconfig
import ftnexport
import ftnimport

db = ftnconfig.connectdb()

bydomain = {}

for domain in ["echo", "fileecho"]:
    #print ("domain", domain)
    for t in ftnexport.get_all_targets(db, domain):
        tid = ftnconfig.get_addr_id(db, db.FTN_domains[domain], t)
        ulist = []
        for x in ftnexport.get_subscribers(db, tid, True):
            ulist.append("%d|%s" % ftnconfig.get_addr(db, x[0]) + "!%d" % x[2])
        #print
        ulist.sort()
        bydomain.setdefault(domain, {}).setdefault(", ".join(ulist),
                                                   []).append(t)

with ftnimport.session(db) as sess:
    for d, byuplink in bydomain.items():
        outp = []
        for u, targets in byuplink.items():
            outp.append("  uplink = [" + u + "]\n")
            targets.sort()
            for t in targets:
                outp.append("    " + t + "\n")
            outp.append("\n")
Ejemplo n.º 3
0
#!/usr/local/bin/python3 -bb

import ftnconfig
import ftnexport
import ftnimport

db = ftnconfig.connectdb()

bydomain = {}

for domain in ["echo", "fileecho"]:
  #print ("domain", domain)
  for t in ftnexport.get_all_targets(db, domain):
    tid = ftnconfig.get_addr_id(db, db.FTN_domains[domain], t)
    ulist = []
    for x in ftnexport.get_subscribers(db, tid, True):
        ulist.append("%d|%s"%ftnconfig.get_addr(db, x[0])+"!%d"%x[2])
    #print 
    ulist.sort()
    bydomain.setdefault(domain, {}).setdefault(", ".join(ulist), []).append(t)


with ftnimport.session(db) as sess:
  for d, byuplink in bydomain.items():
    outp=[]
    for u, targets in byuplink.items():
      outp.append("  uplink = ["+u+"]\n")
      targets.sort()
      for t in targets:
        outp.append("    "+t+"\n")
      outp.append("\n")
Ejemplo n.º 4
0
#!/usr/local/bin/python3 -bb

import ftnconfig
import ftnexport

db = ftnconfig.connectdb()

echoes = ftnexport.get_all_targets(db, "echo")

for echo in echoes:
    addr = ftnconfig.get_addr_id(db, db.FTN_domains["echo"], echo)
    print(echo, ftnexport.count_messages_to(db, addr))
Ejemplo n.º 5
0
def fix(db, sess, src, srcname, destname, domain, password, msgid, cmdtext,
        is_local):
    dom, text = db.prepare(
        "select domain, text from addresses where id=$1").first(src)
    if dom != db.FTN_domains["node"]:
        raise FTNFail("not our domain")
    print("*fix for:", text)
    link_id, addr_id, myaddr_id = ftnaccess.check_link(db, text, password,
                                                       True)
    if myaddr_id is None:
        reply = ["wrong password"]
        raise (Exception("cannot find my address to reply to *fix message"))
    elif link_id is None:
        reply = ["unknown link"]
    elif not is_local:
        reply = [
            "request delivered not directly, please consider changing the password"
        ]
    else:
        reply = []
        for cmd in map(str.strip, cmdtext.upper().strip().split("\n")):
            if cmd.startswith("---"):
                break
            elif len(cmd) == 0:
                continue
            elif cmd.startswith("%PING"):
                reply.append("NOP: " + cmd)
            elif cmd.startswith("%QUERY"):
                for area in ftnexport.get_node_subscriptions(db, text, domain):
                    reply.append(area)
            elif cmd.startswith("%HELP"):
                reply.append("Use following command:")
                reply.append("  %QUERY          -- list of subscribed areas")
                reply.append("  %LIST           -- list of all areas")
                reply.append("  +areaname       -- subscribe, or:")
                reply.append("  areaname        -- subscribe")
                reply.append("  -areaname       -- unsubscribe")
                reply.append(
                    "        you can use ? to substitite any one character an area name"
                )
                reply.append(
                    "        or * to substitude any number of any characters in area name"
                )
                reply.append("        areaname must be UPPERCASE")
                reply.append(
                    "  %RESET area YYYY-MM-DD -- reset area to specified date")
                reply.append("")
            elif cmd.startswith("%LIST"):
                for area in ftnexport.get_all_targets(db, domain):
                    reply.append(area)
            elif cmd.startswith("%AVAIL"):
                reply.append("Sorry not implemented: " + cmd)
            elif cmd.startswith("%PAUSE"):
                reply.append("Sorry not implemented: " + cmd)
            elif cmd.startswith("%RESET"):
                reply += reset(db, sess, text, domain, cmd[7:])
            elif cmd.startswith("-"):
                reply += unsubscribe(db, sess, text, domain, cmd[1:])
            elif cmd.startswith("+"):
                reply += subscribe(db, sess, text, domain, cmd[1:])
            elif cmd.startswith("%"):
                reply.append("Unknown command: " + cmd)
                print(cmd)
#        1/0
            else:
                reply += subscribe(db, sess, text, domain, cmd)

    reply.append("")
    print("*fix reply from:", myaddr_id, ftnconfig.get_taddr(db, myaddr_id))
    sess.send_message(ftnconfig.get_taddr(db, myaddr_id),
                      destname + " Robot", ("node", text),
                      srcname,
                      msgid,
                      "report",
                      "\n".join(reply),
                      sendmode="direct")
    print(reply)
Ejemplo n.º 6
0
#!/usr/local/bin/python3 -bb

import ftnconfig
import ftnexport

db=ftnconfig.connectdb()

echoes = ftnexport.get_all_targets(db, "echo")

for echo in echoes:
  addr=ftnconfig.get_addr_id(db, db.FTN_domains["echo"], echo)
  print (echo, ftnexport.count_messages_to(db, addr))