コード例 #1
0
        private void BlockOutsideDns(uint weight, uint tapInterfaceIndex)
        {
            var callout = _sublayer.CreateCallout(
                new DisplayData
            {
                Name        = "ProtonVPN block dns callout",
                Description = "Sends server failure packet response for non TAP DNS queries.",
            },
                _networkLayerCalloutGuid,
                Layer.OutboundIPPacketV4);

            _sublayer.BlockOutsideDns(new DisplayData("ProtonVPN block DNS", "Block outside dns"),
                                      Layer.OutboundIPPacketV4,
                                      weight,
                                      callout,
                                      tapInterfaceIndex);

            _ipLayer.ApplyToIpv4(layer =>
            {
                _sublayer.CreateRemoteUdpPortFilter(new DisplayData(
                                                        "ProtonVPN DNS filter", "Permit UDP 53 port so we can block it at network layer"),
                                                    Action.HardPermit,
                                                    layer,
                                                    weight,
                                                    53);
            });

            _ipLayer.ApplyToIpv4(layer =>
            {
                _sublayer.CreateRemoteTcpPortFilter(new DisplayData(
                                                        "ProtonVPN block DNS", "Block TCP 53 port"),
                                                    Action.HardBlock,
                                                    layer,
                                                    weight,
                                                    53);
            });

            _ipLayer.ApplyToIpv6(layer =>
            {
                _sublayer.CreateRemoteTcpPortFilter(new DisplayData(
                                                        "ProtonVPN block DNS", "Block TCP 53 port"),
                                                    Action.HardBlock,
                                                    layer,
                                                    weight,
                                                    53);
            });

            _ipLayer.ApplyToIpv6(layer =>
            {
                _sublayer.CreateRemoteUdpPortFilter(new DisplayData(
                                                        "ProtonVPN block DNS",
                                                        "Block UDP 53 port"),
                                                    Action.HardBlock,
                                                    layer,
                                                    weight,
                                                    53);
            });
        }