Coder Social home page Coder Social logo

Comments (6)

zhuhaow avatar zhuhaow commented on June 26, 2024

Attached到extension的进程上调试,十有八九是 GeoIP.database = MMDB("PATH_TO_THE_DATABASE")! 没设

from nekit.

2856571872 avatar 2856571872 commented on June 26, 2024

Attached到extension的进程上调试,十有八九是 GeoIP.database = MMDB("PATH_TO_THE_DATABASE")! 没设

多谢回复,但是问题还是存在。。。
背景是这样,为了适配Xcode 11,我升级了NEKit 的库,目前是swift 4.2。关于连接SS的配置都没变动,PacketTunnel里面的相关配置如下。
情况说明:未加上GeoIP.database = MMDB("PATH_TO_THE_DATABASE")!,连接成功,但是过一会就自动断开。加上了直接就连接失败了
` var address: String = ""
var post: Int = 82
var password: String = ""
var algorithm: CryptoAlgorithm = .CHACHA20
var rulesDic: [String:Any] = [:]

    address = configure[addressKey] as? String ?? ""
    if let postString = configure[portKey] as? String {
        post = Int(postString) ?? 82
    }
    password = configure[passwordKey] as? String ?? ""

    if let algorithmString = configure[methodKey] as? String {
        if algorithmString == "CHACHA20" {
            algorithm = .CHACHA20
        }
        if algorithmString == "AES-128-CFB" {
            algorithm = .AES128CFB
        }
        if algorithmString == "AES-192-CFB" {
            algorithm = .AES192CFB
        }
        if algorithmString == "AES-256-CFB" {
            algorithm = .AES256CFB
        }
        if algorithmString == "SALSA20" {
            algorithm = .SALSA20
        }
        if algorithmString == "RC4-MD5" {
            algorithm = .RC4MD5
        }
    }
    
    if let rulesDicJsonData = (configure[rulesKey] as? String)?.data(using: String.Encoding.utf8) {
        if let rules = (try? JSONSerialization.jsonObject(with:rulesDicJsonData, options: [])) as? [String:Any] {
            rulesDic = rules
        }
    }

    // 协议混淆
    let obfuscater = ShadowsocksAdapter.ProtocolObfuscater.OriginProtocolObfuscater.Factory()

    // 算法
    let cryptor = ShadowsocksAdapter.CryptoStreamProcessor.Factory(password: password, algorithm: algorithm)

    let stream = ShadowsocksAdapter.StreamObfuscater.OriginStreamObfuscater.Factory()

// GeoIP.database = MMDB("/path/GeoIP2-City.mmdb")!

    // ss适配器
    let ssAdapterFactory = ShadowsocksAdapterFactory(serverHost: address, serverPort: post, protocolObfuscaterFactory: obfuscater, cryptorFactory: cryptor, streamObfuscaterFactory: stream)

    // 直连适配器
    let directAdapterFactory = DirectAdapterFactory()

    // 设置用户规则
    var userRules:[Rule] = []

    // 直连规则
    let directRules = cofigureAdapter(adapter: directAdapterFactory, parameters: rulesDic[directKey] as? [String : Any])
    // 代理规则
    let adapterRules = cofigureAdapter(adapter: ssAdapterFactory, parameters: rulesDic[proxyAdapterKey] as? [String : Any])

    // 注意: 谁先放在前面,谁的优先级就比较高

    userRules.append(contentsOf: adapterRules)
    userRules.append(contentsOf: directRules)
    
    // 其他规则
    let unKnowLoc = CountryRule(countryCode: "--", match: true, adapterFactory: ssAdapterFactory)

    let dnsFailRule = DNSFailRule(adapterFactory: ssAdapterFactory)

    let allRule = AllRule(adapterFactory: ssAdapterFactory)

    userRules.append(contentsOf: [unKnowLoc,dnsFailRule,allRule])

    let manager = RuleManager(fromRules: userRules, appendDirect: true)
    RuleManager.currentManager = manager`

from nekit.

zhuhaow avatar zhuhaow commented on June 26, 2024

from nekit.

2856571872 avatar 2856571872 commented on June 26, 2024

extension
attach停在了这
image

image

from nekit.

2856571872 avatar 2856571872 commented on June 26, 2024

大佬,能帮忙分析下原因吗。。

from nekit.

zhuhaow avatar zhuhaow commented on June 26, 2024

image

不是显示在这了

from nekit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.