Esempio 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)
Esempio n. 2
0
  with ftnimport.session(db) as sess:
    fix(db, sess, src, sn, "AreaFix", "echo", h, mi, b, is_local)
    db.prepare("update messages set processed=1 where id=$1")(id_msg)
    

for id_msg, src, _, sn, h, mi, b, is_local in fixes_f:
  with ftnimport.session(db) as sess:
    fix(db, sess, src, sn, "FileFix", "fileecho", h, mi, b, is_local)
    db.prepare("update messages set processed=1 where id=$1")(id_msg)

exit()

#for s in ftnexport.get_node_subscriptions(db, "2:5020/12000", "node"):
#  print(db.prepare("select a.domain, a.text from addresses a, subscriptions s where s.id=$1 and a.id=s.target")(s)[0])


for sub_id, target_id, lastsent in ftnexport.get_node_subscriptions(db, ADDRESS, "node"):
  print(sub_id, ": mail directed to", 
        db.prepare("select a.domain, a.text from addresses a, subscriptions s where s.id=$1 and a.id=s.target").first(sub_id))
  
  for id_msg, srcdom, srctext, msgid, header, body, recvfrom in ftnexport.get_messages(db, target_id, lastsent):
    print("*************"+str(id_msg)+"*"+msgid+"*****************")
    print("From:", header.find("sendername").text.encode("utf-8"), srcdom,srctext)
    print("To  :", header.find("recipientname").text.encode("utf-8"), "node",ADDRESS)
    print("Date:", header.find("date").text.encode("utf-8"))
    print("Subj:", header.find("subject").text.encode("utf-8"))
    print(body.encode("utf-8"))
    # process
    # if fail abort
    # if ok update watermark update_subscription_watermark(db, localnetmailsubscription, id_msg)
Esempio n. 3
0
    sess.check_addr(domain, area)
    sess.add_subscription(True, domain, area, subscriber)
    if subscriber != ftnconfig.ADDRESS:
      sess.send_message(my_addr, ftnconfig.SYSOP, ("node", subscriber), robot, None, pw, "+"+area, sendmode="direct")
    else:
      print ("local subscription")

  elif cmd == "query": # send areafix request
    sess.send_message(my_addr, ftnconfig.SYSOP, ("node", subscriber), robot, None, pw, "%QUERY", sendmode="direct")

  elif cmd == "list": # send areafix request
    sess.send_message(my_addr, ftnconfig.SYSOP, ("node", subscriber), robot, None, pw, "%LIST", sendmode="direct")

  elif cmd == "show": # show subscribed areas
    if area==".": # show for link
      for x in ftnexport.get_node_subscriptions(db, subscriber, domain):
        print (x)
    else: # show from area
      tid =  ftnconfig.get_addr_id(db, db.FTN_domains[domain], area)
      print (tid)
      for aid, vital, level in ftnexport.get_subscribers(db, tid):
        print (ftnconfig.get_addr(db, aid))

  elif cmd == "showuplink": # show areas subsribed as vital
    if area==".": # show for link
      for x in ftnexport.get_node_subscriptions(db, subscriber, domain, asuplink=True):
        print (x)
    else: # show from area
      tid =  ftnconfig.get_addr_id(db, db.FTN_domains[domain], area)
      print (tid)
      for x in ftnexport.get_subscribers(db, tid, True):
Esempio n. 4
0
                          pw,
                          "%QUERY",
                          sendmode="direct")

    elif cmd == "list":  # send areafix request
        sess.send_message(my_addr,
                          ftnconfig.SYSOP, ("node", subscriber),
                          robot,
                          None,
                          pw,
                          "%LIST",
                          sendmode="direct")

    elif cmd == "show":  # show subscribed areas
        if area == ".":  # show for link
            for x in ftnexport.get_node_subscriptions(db, subscriber, domain):
                print(x)
        else:  # show from area
            tid = ftnconfig.get_addr_id(db, db.FTN_domains[domain], area)
            print(tid)
            for aid, vital, level in ftnexport.get_subscribers(db, tid):
                print(ftnconfig.get_addr(db, aid))

    elif cmd == "showuplink":  # show areas subsribed as vital
        if area == ".":  # show for link
            for x in ftnexport.get_node_subscriptions(db,
                                                      subscriber,
                                                      domain,
                                                      asuplink=True):
                print(x)
        else:  # show from area
Esempio 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)
Esempio n. 6
0
for id_msg, src, _, sn, h, mi, b, is_local in fixes_f:
    with ftnimport.session(db) as sess:
        print("fix:", sess, src, sn, "AreaFix", "echo", h, mi, b, is_local)
        try:
            fix(db, sess, src, sn, "FileFix", "fileecho", h, mi, b, is_local)
            db.prepare("update messages set processed=1 where id=$1")(id_msg)
        except Exception as e:
            print(e)
            continue

exit()

#for s in ftnexport.get_node_subscriptions(db, "2:5020/12000", "node"):
#  print(db.prepare("select a.domain, a.text from addresses a, subscriptions s where s.id=$1 and a.id=s.target")(s)[0])

for sub_id, target_id, lastsent in ftnexport.get_node_subscriptions(
        db, ADDRESS, "node"):
    print(
        sub_id, ": mail directed to",
        db.prepare(
            "select a.domain, a.text from addresses a, subscriptions s where s.id=$1 and a.id=s.target"
        ).first(sub_id))

    for id_msg, srcdom, srctext, msgid, header, body, recvfrom in ftnexport.get_messages(
            db, target_id, lastsent):
        print("*************" + str(id_msg) + "*" + msgid +
              "*****************")
        print("From:",
              header.find("sendername").text.encode("utf-8"), srcdom, srctext)
        print("To  :",
              header.find("recipientname").text.encode("utf-8"), "node",
              ADDRESS)