wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
From: Feng Li <lifeng1519@gmail.com>
To: Kassem Omega <kassemomega@gmail.com>
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: Suggestion for WireGuard
Date: Thu, 2 Sep 2021 12:54:21 +0800	[thread overview]
Message-ID: <CAEK8JBBocnGRt7yFdVqm6Oou-UCYmtO26bzvB=YE7j9BDdjkTw@mail.gmail.com> (raw)
In-Reply-To: <CAJaZ5dPHbc5s=JiCbuBKAGf1Nb3vw0xL9W7_=Na4Skt_pjnWZw@mail.gmail.com>

I have asked this question some months ago like you,
and don't get my answer, this is a workaround from me
to calculate the AllowedIPs, maybe can help you:

import ipaddress

def address_exclude(rr, r1):
    out = []
    for r in rr:
        if r1.subnet_of(r):
            out += list(r.address_exclude(r1))
    return out

def calc_exclude(includes, excludes):
    includes_addr = [ ipaddress.ip_network(i) for i in includes ]
    excludes_addr = [ ipaddress.ip_network(e) for e in excludes ]

    for e in excludes_addr:
        includes_addr = address_exclude(includes_addr, e)
    strs = [str(i) for i in includes_addr]
    print("AllowedIPs = " + ",".join(strs))

calc_exclude(includes=[''], excludes=['', ''])

I have asked this question here too:

On Wed, Sep 1, 2021 at 9:50 PM Kassem Omega <kassemomega@gmail.com> wrote:
> Hi,
> I sent this before a couple of times to the mailing list but either it
> didn't go through or it is forbidden somehow? I never got any decision
> from the list moderator that it is forbidden to send suggestions at
> all. Hopefully someone can answer with anything.
> I was wondering if there is any chance of adding the opposite of
> AllowedIPs option to WireGuard?
> Currently, WireGuard has a whitelist option only that specifies which
> IPs to go through it, however I believe adding the blacklist option
> would be beneficial and easier to configure.
> The use case: allowing all traffic to go through WireGuard except
> specific ranges.
> Right now to do this I must use this long list of ranges to achieve this:
> AllowedIPs =,,,,,
> However, if the DisallowedIPs option is available, I'd simply use:
> DisallowedIPs =,
> What do you think?
> Thank you.
> Kassem

  parent reply	other threads:[~2021-09-02  4:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 13:19 Suggestion for WireGuard Kassem Omega
2021-09-02  4:10 ` Guy Godfroy
2021-09-02  4:54 ` Feng Li [this message]
2021-09-02 13:46 ` Lonnie Abelbeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEK8JBBocnGRt7yFdVqm6Oou-UCYmtO26bzvB=YE7j9BDdjkTw@mail.gmail.com' \
    --to=lifeng1519@gmail.com \
    --cc=kassemomega@gmail.com \
    --cc=wireguard@lists.zx2c4.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).