AdguardTeam / AdGuardHome

Network-wide ads & trackers blocking DNS server
https://adguard.com/adguard-home/overview.html
GNU General Public License v3.0
25.57k stars 1.84k forks source link

Add a proxy server to AdGuard Home #391

Closed Rediwed closed 4 years ago

Rediwed commented 6 years ago

Hi!

I wasn't sure where to post this, since this is not really an issue.

I'm interested in your Adguard Home product (the one from the recent newsletter). I've been thinking about setting up a computer to do some background ad-filtering, act as a VPN server and to act as a Traffic server. Basically; my home network is extremely fast, but I've only got a 20-30mbps downspeed. I wanted to speed up page loading, and file downloads by setting up Apache Traffic Server as a tiny, local, content distributor.

So my question is, is there any change Adguard Home can be (or might be able to in the future) set-up for other networking tools as well?

With kind regards,

A happy premium member.

ameshkov commented 6 years ago

I guess even in the current state of AG Home, you can combine it with a proxy/VPN, but that'd require some additional configuration.

Or would you like us to include a proxy server in AG Home eventually?

hoshsadiq commented 5 years ago

Sorry to jump in on this but I'd say the second. Combining this with a proxy/VPN will limit blocking to just DNS still, however, if there is a HTTP/S proxy option besides DNS, cosmetic adblock rules can be apply for anything that DNS doesn't block (rules which I'm guessing are currently ignored). This will result in having adblocking within browsers that do not support any adblocking extensions (looking at you chrome for android and browsers within TVs).

hoshsadiq commented 5 years ago

There's several go proxy libraries out there than can be potentially used. Best one I could find (at least it looks most well maintained) is https://github.com/elazarl/goproxy

ameshkov commented 5 years ago

@hoshsadiq well, here you can take a look at me experimenting with migrating AdGuard filtering engine to Go: https://github.com/AdguardTeam/urlfilter

There's even an example that uses goproxy (no cosmetic filters yet).

It will take quite more time to implement something feasible, though. Also, goproxy appears to be rather problematic and not really well maintained. I had to fork it and fix the most pressing issues: https://github.com/ameshkov/goproxy

hoshsadiq commented 5 years ago

Wow! You're way ahead of me. This is great.

Is urlfilter currently used by adguard home?

I'm thinking perhaps it's a possibility to provide three binaries, DNS only, Proxy only, and both combined. Reason being that people may want only DNS, or only proxy and both combined simply because that would mean you don't have to duplicate configuration and lists and it can all automagically work.

Is there a reason you've not made a PR to upstream?

It will take quite more time to implement something feasible, though.

Totally get that. I'd be happy to try and help. I will fork both repos over the weekend, and see what I can cook up.

ameshkov commented 5 years ago

Is urlfilter currently used by adguard home?

It's not finished so not yet.

At first, we will use it's DNSEngine instead of the current one (as it brings some really important memory improvements).

What for the proxy implementation, I need to finish with the implementation of cosmetic rules, and only after that, we will add it as an experimental feature to AGH.

adrianh-za commented 5 years ago

I would love AG Home to have built in socks proxy server

Omoeba commented 5 years ago

I will be great if AGH also can create an interface and filter any traffic routed through that interface with an option to forward that traffic to another interface. That way AGH can receive traffic from TUN0, filter it, and then send it to ETH0 (the actual network interface).

ameshkov commented 5 years ago

Can't it be achieved with tun2socks or smth like that?

Omoeba commented 5 years ago

I don't think tun2socks can do anything with outgoing traffic

ameshkov commented 5 years ago

Why that's exactly what it does: reads from the TUN interface, reroutes it to a SOCKS proxy (which does all the filtering), and then writes back to the TUN interface.

R9980 commented 5 years ago

act as a VPN server and to act as a Traffic server.

@ameshkov so will we able to have another 'usage log' (hosts - both domains/ip) additional to 'query log' for web user interface with inbound/outbound bandwidth for each hosts?

ameshkov commented 5 years ago

@Cloud-O yes, the proxy server will have a different log

R9980 commented 5 years ago

Cool!

ameshkov commented 5 years ago

A quick update on this issue.

It takes more time than anticipated. It appeared that there are no good HTTP proxies implementations we can use for this purpose. elazarl/goproxy has some serious design flaws, google/martian is too complicated for our purpose.

Long story short, we had to come up with our own implementation that will be used as a basis for the AdGuard Home filtering proxy: https://github.com/AdguardTeam/gomitmproxy

This feature request is now assigned to the v0.102 milestone.

ameshkov commented 5 years ago

If anyone wants to play with the first content blocking proxy implementation, you can try it here: https://github.com/AdguardTeam/urlfilter/tree/master/cmd

There you can find instruction on how to build and run it.

szolin commented 4 years ago

See #1228