zhuhaow / NEKit

A toolkit for Network Extension Framework
https://zhuhaow.github.io/NEKit
BSD 3-Clause "New" or "Revised" License
2.84k stars 671 forks source link

Reject rule takes too many time #82

Closed devstar1988 closed 5 years ago

devstar1988 commented 7 years ago

Hello

I am now trying to use this framework. Btw, when i use reject rule for blocking some hosts, it takes too many time.

Specially, Youtube video loading is very slow. Can you investigate about this?

zhuhaow commented 7 years ago

Try if you can reproduce this with Chrome

devstar1988 commented 7 years ago

Yes, I can reproduce this with Chrome also.

Specially, when I browse sites with many advertisement, it takes too many time.

On 19 May 2017, at 8:00 PM, zhuhaow notifications@github.com wrote:

Try if you can reproduce this with Chrome

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zhuhaow/NEKit/issues/82#issuecomment-302684365, or mute the thread https://github.com/notifications/unsubscribe-auth/AOjPY8I6RG_AhScQoL6sZMqx4tZEMc9cks5r7YRMgaJpZM4NgbtM.

devstar1988 commented 7 years ago

let rejectAdapterFactory = RejectAdapterFactory(delay: 300)

Reject has delay for 300 ms. Is this wrong?

I referenced Specht project.

zhuhaow commented 7 years ago

Take a look at how things are loaded in developer tools

devstar1988 commented 7 years ago

mathid.mathtag.com bid.contextweb.com adserver-us.adtech. ib.adnxs.com com.googletagservi.. s.komoona.com as.casalemedia.com ap.lijit.com media.msg.dotomi.com www.google-analytics. googleads.g.doubleclick

These are blocked by reject rules. but site loading is delayed.

devstar1988 commented 7 years ago

These are from "whatismyipaddress.com".

zhuhaow commented 7 years ago

How are things loaded?

devstar1988 commented 7 years ago

I added this domains in reject rule, so those are blocked. Site is loaded completely, but it still shows progress bar.

On 25 May 2017, at 7:59 PM, zhuhaow notifications@github.com wrote:

How are things loaded?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zhuhaow/NEKit/issues/82#issuecomment-303993022, or mute the thread https://github.com/notifications/unsubscribe-auth/AOjPY9AP9jeSq34XwxvuLvtXCXOkveF4ks5r9W0vgaJpZM4NgbtM.

zhuhaow commented 7 years ago

Then what is still loading?

On 25 May 2017, at 20:05, devstar1988 notifications@github.com wrote:

I added this domains in reject rule, so those are blocked. Site is loaded completely, but it still shows progress bar.

On 25 May 2017, at 7:59 PM, zhuhaow notifications@github.com wrote:

How are things loaded?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zhuhaow/NEKit/issues/82#issuecomment-303993022, or mute the thread https://github.com/notifications/unsubscribe-auth/AOjPY9AP9jeSq34XwxvuLvtXCXOkveF4ks5r9W0vgaJpZM4NgbtM.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zhuhaow/NEKit/issues/82#issuecomment-303994263, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOmLGR3OYPWLqm8NFEgDShaSz7GOF6Gks5r9W57gaJpZM4NgbtM.

devstar1988 commented 7 years ago

Not loading, but just show progress bar only. Site is successfully loaded.

I think that progress bar counts total page vs loaded page. But, reject adapter disconnects hosts contained in reject rule.

So, progress bar may not count blocked pages and shows it still not loaded.

I think that you have to block hosts contained in reject list, just return http code 200 with empty page like Potatso.

On 25 May 2017, at 8:07 PM, zhuhaow notifications@github.com wrote:

Then what is still loading?

On 25 May 2017, at 20:05, devstar1988 notifications@github.com wrote:

I added this domains in reject rule, so those are blocked. Site is loaded completely, but it still shows progress bar.

On 25 May 2017, at 7:59 PM, zhuhaow notifications@github.com wrote:

How are things loaded?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zhuhaow/NEKit/issues/82#issuecomment-303993022, or mute the thread https://github.com/notifications/unsubscribe-auth/AOjPY9AP9jeSq34XwxvuLvtXCXOkveF4ks5r9W0vgaJpZM4NgbtM.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zhuhaow/NEKit/issues/82#issuecomment-303994263, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOmLGR3OYPWLqm8NFEgDShaSz7GOF6Gks5r9W57gaJpZM4NgbtM.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zhuhaow/NEKit/issues/82#issuecomment-303994712, or mute the thread https://github.com/notifications/unsubscribe-auth/AOjPYy-drSRKYcXymYntWM8cP43yh2hbks5r9W7ngaJpZM4NgbtM.

itskeKs commented 7 years ago

they will be delayed since ads nowadays are loaded through https. this will end up in certificate errors and resultbin depayed loafing times. thats why dns adblocking like pihole are useless. i guess these reject rules are also somekind of dns redirects to localhost?!

zhuhaow commented 7 years ago

No, the connection is just closed.

在 2017年5月25日,20:11,itskeKs notifications@github.com 写道:

they will be delayed since ads nowadays are loaded through https. this will end up in certificate errors and resultbin depayed loafing times. thats why dns adblocking like pihole are useless. i guess these reject rules are also somekind of dns redirects to localhost?!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

devstar1988 commented 7 years ago

Yes,

Because connection is closed, browser will not count that page was not loaded. So, progress bar will show that site is still loading even though site was loaded completely.

On 25 May 2017, at 8:14 PM, zhuhaow notifications@github.com wrote:

No, the connection is just closed.

Zhuhao Wang

在 2017年5月25日,20:11,itskeKs notifications@github.com 写道:

they will be delayed since ads nowadays are loaded through https. this will end up in certificate errors and resultbin depayed loafing times. thats why dns adblocking like pihole are useless. i guess these reject rules are also somekind of dns redirects to localhost?!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zhuhaow/NEKit/issues/82#issuecomment-303996173, or mute the thread https://github.com/notifications/unsubscribe-auth/AOjPY0n34x7-uz1tiYt7oZQ8NN9lNexWks5r9XC-gaJpZM4NgbtM.

devstar1988 commented 7 years ago

override public func openSocketWith(session: ConnectSession) { super.openSocketWith(session: session)

    QueueFactory.getQueue().asyncAfter(deadline: DispatchTime.now() + DispatchTimeInterval.milliseconds(delay)) {
        [weak self] in
        self?.disconnect()
    }
}

Here

self?.disconnect()

I think that it should not be.

self?.didRead(data, ...)

data will be HTTP response with code 200, empty page. This will help something?

devstar1988 commented 7 years ago

Hello, no have solution?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.