TunnelProvider Crashing with Fatal Error in WireGuard Kit VPN Application

Title: TunnelProvider Crashing with Fatal Error in WireGuard Kit VPN Application

Body:

Hi everyone,

I’m working on building a VPN application based on the WireGuard Kit, but I’m encountering a strange issue where the TunnelProvider crashes with a fatal error. I would really appreciate any help or insights on how to resolve this problem.

Here’s a detailed description of the issue:

Error Message:

Fatal error: self must be a properly aligned pointer for types Pointee and T

Logs:

default17:46:09.277187+0300TunnelProviderExtension /private/var/containers/Bundle/Application/60D347EC-2894-45C1-B131-7C14350A8DC9/Coro.app/PlugIns/TunnelProvider.appex/TunnelProvider of type: (null) launched.
default17:46:09.277236+0300TunnelProviderHello, I’m launching as euid = 501, uid = 501, personaid = 1000, type = DEFAULT, name = 
default17:59:54.991718+0300TunnelProvider[Extension net.coro.mobileprotection.TunnelProvider]: Calling startTunnelWithOptions with options 0x0
default17:59:54.991831+0300TunnelProviderRequesting app group container lookup; personaid = 1000, type = DEFAULT, name = ACC421CC-07D3-4B7A-A105-E3667FCF6E7F, origin [pid = 3112, personaid = 99], proximate [pid = 3495, personaid = 199], identifier = , euid = 501, uid = 501, platform = 2
default17:59:54.995994+0300TunnelProvider[LOG] Starting tunnel from the OS directly, rather than the app
default17:59:54.996017+0300TunnelProvider[LOG] Loaded configuration from provider configuration.
default17:59:54.996438+0300TunnelProvidernw_path_evaluator_start [99AE5F38-3D18-4F00-9306-95AE30A04EA2  generic, multipath service: 1, attribution: developer]
path: satisfied (Path is satisfied), interface: pdp_ip0[lte], scoped, ipv6, dns, expensive, uses cell
default17:59:54.996507+0300TunnelProvidernw_path_libinfo_path_check [AE278BF5-3C14-4694-AC4E-B39EE4493A5D Hostname#4fec4f59:1024 tcp, legacy-socket, attribution: developer]
libinfo check path: satisfied (Path is satisfied), interface: pdp_ip0[lte], scoped, ipv6, dns, expensive, uses cell
default17:59:55.001566+0300TunnelProviderSwift/arm64-apple-ios.swiftinterface:24059: Fatal error: self must be a properly aligned pointer for types Pointee and T

VPN Configuration I’m Using (Free VPN) that works on macOS official app:

[Interface]
Address = 192.168.6.217/32
DNS = 1.1.1.1,8.8.8.8
PrivateKey = mCFRvM8LShpTq6Zhanr8yCu65zYAiGB4jUWCli/EAWo=

[Peer]
publickey=/34Vt3UbFYMBM7UIVGl/AEoGFXPHrdwylJL7zKamHB0=
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = az1.vpnjantit.com:1024

iOS Code:

private func connect() async throws {
    NETunnelProviderManager.loadAllFromPreferences { (managers, error) in
        guard error == nil else {
            print("Error loading managers: (error!)")
            return
        }
        
        let manager = managers?.first ?? NETunnelProviderManager()
        
        let protocolConfiguration = NETunnelProviderProtocol()
        protocolConfiguration.providerBundleIdentifier = "***.***.*****.TunnelProvider"
        
        let wgQuickConfig = """
        [Interface]
        Address = 192.168.6.217/32
        DNS = 1.1.1.1,8.8.8.8
        PrivateKey = mCFRvM8LShpTq6Zhanr8yCu65zYAiGB4jUWCli/EAWo=
        
        [Peer]
        publickey=/34Vt3UbFYMBM7UIVGl/AEoGFXPHrdwylJL7zKamHB0=
        AllowedIPs = 0.0.0.0/0, ::/0
        Endpoint = az1.vpnjantit.com:1024
        """
        
        protocolConfiguration.providerConfiguration = ["wgQuickConfig": wgQuickConfig]
        protocolConfiguration.serverAddress = "az1.vpnjantit.com:1024"
        
        manager.protocolConfiguration = protocolConfiguration
        manager.localizedDescription = "WireGuard VPN"
        manager.isEnabled = true
        
        manager.saveToPreferences { error in
            if let error = error {
                print("Error saving preferences: (error)")
            } else {
                print("Saved preferences successfully")
                
                NETunnelProviderManager.loadAllFromPreferences { (managers, error) in
                    guard let manager = managers?.first, error == nil else {
                        print("Error loading VPN configurations: (error!)")
                        return
                    }
                    
                    do {
                        try manager.connection.startVPNTunnel()
                        print("VPN started successfully")
                    } catch {
                        print("Error starting VPN: (error)")
                    }
                }
            }
        }
    }
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật