Пример #1
0
    def readGuiConfig(self, filename):
        pv2rc = ParserV2RayClash()
        v2rnp = ParserV2RayN()
        rawGuiConfigs = pv2rc.parseGuiConfig(filename)
        if (rawGuiConfigs == False):
            logger.info("Not Clash Config.")
            rawGuiConfigs = v2rnp.parseGuiConfig(filename)
            if (rawGuiConfigs == False):
                logger.info("Not V2RayN Config.")
                logger.critical("Gui config parse failed.")
                rawGuiConfigs = []

        for _dict in rawGuiConfigs:
            _cfg = self.__generateConfig(_dict)
            #	logger.debug(_cfg)
            self._configList.append(_cfg)
        logger.info("Read %d node(s)" % len(self._configList))
Пример #2
0
 def readSubscriptionConfig(self, url):
     header = {
         "User-Agent":
         "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"
     }
     rep = requests.get(url, headers=header, timeout=15)
     rep.encoding = "utf-8"
     rep = rep.content.decode("utf-8")
     try:
         linksArr = (b64plus.decode(rep).decode("utf-8")).split("\n")
         for link in linksArr:
             link = link.strip()
             #	print(link)
             cfg = self._parseLink(link)
             if (cfg):
                 #	print(cfg["remarks"])
                 self._configList.append(cfg)
     except ValueError:
         logger.info("Try V2Ray Clash Parser.")
         pv2rc = ParserV2RayClash()
         self._configList = pv2rc.parseSubsConfig(rep)
     logger.info("Read %d node(s)" % len(self._configList))