Development :  K-Meleon Forum
K-Meleon development related discussions. 
[SOLVED!] How to preconfigure proxy setting in custom KM build?
Posted by: rodocop
Date: October 31, 2017 10:36PM

Hi all, folks!
My problem is about how to 'preinstall' my proxy into Pro-build.

Simple adding 'default preferences' doesn't help as there are dinamically updated Proxy menu - this gets made by the script inside KmPrefs Proxy XUL (pref-proxy.xul)

So when I try to predefine my proxy by prefs - it doesn't work.

Are there any ideas about how to make this?


Latest Release KM75.1 Latest dev KM76RC ||| Visit The K-Meleon Place and join me there!
Old good stuff: KM-1.6db+NS © dugbugoffice // KM-16-S2014 © Fred // KM-1.6beta2.6 © JamesD // KM Twin+ © rodocop // KM 1.8.24.22 © adodupan

RECOMMENDED! K-Meleon 76 Pro ==» Download portable: 7zip or EXE =//= Discuss on forum
K-Meleon 75.1 Pro: Download =//= Discuss || Portable Flash plugin (x86/x64 DLLs)



Edited 1 time(s). Last edit at 11/01/2017 02:01PM by rodocop.

Options: ReplyQuote
Re: [QUESTION] How to preconfigure proxy setting in custom KM build?
Posted by: JamesD
Date: November 01, 2017 11:18AM

I have never used a proxy myself, but looking at the preferences (F2) for Network Performance - Proxy - General, there is an item called "Use the following user defined proxy configuration". Is it possible to make a user defined config and set whatever pref/switch such that item is not grayed out but is used? This may be what you are trying.

Can you tell me how to make a simple proxy? Maybe then I could test.

:::--------------------------
JamesD



Edited 1 time(s). Last edit at 11/01/2017 11:22AM by JamesD.

Options: ReplyQuote
Re: [QUESTION] How to preconfigure proxy setting in custom KM build?
Posted by: rodocop
Date: November 01, 2017 11:42AM

The trick is that you should HAVE IT ALREADY SET, this proxy - in order to use this option.

And setting the proxy is the manual realtime dynamic procedure made through proxy config (New Configuration) and backended with script, built in XUL-file along with proxy.kmm macro.

Macro creates menu at startup (as always) and script updates it with new Proxy name in real-time while defining this new one.

My problem is that I cannot get how to force KM to create new menu item for my [predefined] proxy.
May be I should create new macro using the same script (but I cannot understand all this stuff

I think this is the part of that script from pref-proxy.xul (it uses JS-Bridge functions also):

	init : function () {
		this.list.value = [];
		this.name.value = [];
		
		var lst = getPrefValue(this.base + this.list.pref);
		if (lst) {
			lst = lst.split(";");
			for (var i = 0; i < lst.length; i++)
				if (lst != "") {
					this.list.value[this.list.value.length] = lst;
					this.name.value[this.name.value.length] = getPrefValue(this.base + lst + this.name.pref);
				}
		} // else
		//	this.compatibility();
		
		var v = getPrefValue(this.base + this.crrnt.pref);
		this.crrnt.value = (v == null && this.list.value.length) ? this.list.value[0] : v;
		
		this._setDefaults();
		this._initMenulist();
		
		this._initTab(this.temp);
		this._setControls("new");
		
		for (var i = 0; i < this.list.value.length; i++)
			this._createTab(i);
		this._setButtonState();
	},
	compatibility : function () {
		// check for old (macro-generated) configurations
		var oldID = this._getNextListID(),
		oldName = getPrefValue(this.base + oldID + this.name.pref);
		while (oldName) {
			this.list.value[this.list.value.length] = oldID;
			this.name.value[this.name.value.length] = oldName;
			
			// move these prefs:
			pref.setIntPref(this.base + oldID + this.pref.name[6], pref.getIntPref(this.base + oldID + this.pref.name[6].replace(/\.proxy/, "")));
			restoreDefault(this.base + oldID + this.pref.name[6].replace(/\.proxy/, ""));
			setCharPref(this.base + oldID + this.pref.name[13], getPrefValue(this.base + oldID + this.pref.name[13].replace(/\.proxy/, "")));
			restoreDefault(this.base + oldID + this.pref.name[13].replace(/\.proxy/, ""));
			
			oldID = this._getNextListID();
			oldName = getPrefValue(this.base + oldID + this.name.pref);
		}
		if (this.list.value.length)
			setCharPref(this.base + this.list.pref, this.list.value.join(";") + (";"));
		for (var i = 0; i < this.list.value.length; i++)
			for (var j = 0, p, v; j < this.pref.name.length; j++) {
				p = this.base + this.list.value + this.pref.name[j];
				v = getPrefValue(p);
				if (v == null) {
					v = this.pref.dflt[j];
					switch (this.pref.type[j]) {
					case 0:
						pref.setBoolPref(p, (v == "true"));
						break;
					case 1:
						pref.setIntPref(p, parseInt(v));
						break;
					case 2:
						setCharPref(p, v);
					}
				}
			}
		
		// check whether any proxy was set through the pre-1.5 native pref panel
		var a = [],
		old = false;
		for (i = 0; i < this.pref.name.length; i++)
			switch (i) {
			case 0:
				a = this.pref.dflt;
				break; // type
			case 11:
				a = "";
				break; // name
			default:
				a = getPrefValue("network" + this.pref.name);
				if (a != this.pref.dflt)
					old = true;
			}
		if (old) {
			oldID = this._getNextListID();
			oldName = document.getElementById("prox_bundle").getString("default_name").replace("%S", oldID.replace("proxy", ""));
			this.list.value[this.list.value.length] = oldID;
			this.name.value[this.name.value.length] = oldName;
			a[0] = (a[12]) ? "2" : "1"; // PAC or manual?
			a[11] = oldName;
			setCharPref(this.base + this.list.pref, this.list.value.join(";") + (";"));
			for (i = 0; i < this.pref.name.length; i++) {
				p = this.base + oldID + this.pref.name;
				v = a;
				switch (this.pref.type) {
				case 0:
					pref.setBoolPref(p, (v == "true"));
					break;
				case 1:
					pref.setIntPref(p, parseInt(v));
					break;
				case 2:
					setCharPref(p, v);
				}
			}
		}
		
		// update menu
		for (i = 0; i < this.list.value.length; i++)
			this._addMenu(this.list.value);
	},
	apply : function (prefID) {
		if (prefID) {
			for (var i = 0, p, v; i < this.pref.name.length; i++) {
				p = "network" + this.pref.name;
				v = getPrefValue(this.base + prefID + this.pref.name);
				switch (this.pref.type) {
				case 0:
					pref.setBoolPref(p, (v == "true"));
					break;
				case 1:
					pref.setIntPref(p, parseInt(v));
					break;
				case 2:
					pref.setCharPref(p, v);
				}
			}
			this.crrnt.value = prefID;
			setCharPref(this.base + this.crrnt.pref, prefID)
			this._initMenulist();
			this._setButtonState();
		}
	},
	add : function () {
		if (this._invalidName())
			return;
		
		var id = this._getNextListID();
		
		for (var i = 0, p, v; i < this.pref.name.length; i++) {
			p = this.base + id + this.pref.name;
			v = getPrefValue(this.base + this.temp + this.pref.name);
			switch (this.pref.type) {
			case 0:
				pref.setBoolPref(p, (v == "true"));
				break;
			case 1:
				pref.setIntPref(p, parseInt(v));
				break;
			case 2:
				setCharPref(p, v);
			}
		}
		
		this.list.value[this.list.value.length] = id;
		this.name.value[this.name.value.length] = getPrefValue(this.base + id + this.name.pref);
		
		if (this.crrnt.value == null) {
			setCharPref(this.base + this.crrnt.pref, id);
			this.crrnt.value = id;
		}
		
		v = getPrefValue(this.base + this.list.pref);
		setCharPref(this.base + this.list.pref, (v == null ? "" : v) + id + ";");
		
		this._addMenu(id);
		this._initMenulist();
		this._createTab(this.list.value.length - 1);
		
		this._setDefaults();
		this._initTab(this.temp);
		this._setControls("new");
		
		this.selectTab(id);
	},


Latest Release KM75.1 Latest dev KM76RC ||| Visit The K-Meleon Place and join me there!
Old good stuff: KM-1.6db+NS © dugbugoffice // KM-16-S2014 © Fred // KM-1.6beta2.6 © JamesD // KM Twin+ © rodocop // KM 1.8.24.22 © adodupan

RECOMMENDED! K-Meleon 76 Pro ==» Download portable: 7zip or EXE =//= Discuss on forum
K-Meleon 75.1 Pro: Download =//= Discuss || Portable Flash plugin (x86/x64 DLLs)



Edited 1 time(s). Last edit at 11/01/2017 11:44AM by rodocop.

Options: ReplyQuote
Re: [QUESTION] How to preconfigure proxy setting in custom KM build?
Posted by: siria
Date: November 01, 2017 12:37PM

Yikes, forget about that script, can't believe such a horror should be necessary...
What about the proxtog2/3 macro a few years ago? In my memory simple pref settings were enough for predefining proxies (hope remember right)
With a bit luck that stuff hasn't changed fundamentally between KM1.6 and 76, so may be able to play with it myself.

Just the prob: still "sitting on the cable" what you mean exactly, where the prob is exactly... perhaps screenshots would help?

Options: ReplyQuote
Re: [QUESTION] How to preconfigure proxy setting in custom KM build?
Posted by: anonymous
Date: November 01, 2017 01:48PM

@rodocop

The part of 'pref-proxy.xul' you pasted was modified by the forum editor. If it was a custom version, you can attach a file or post a link to a file.

It was possible to configure custom proxy settings for all of Fred's packages and for all K-Meleon packages available on Sourceforge.

If you post the custom proxy preference settings you tried to add to your browser, it will be easy to find invalid or missing settings.

It would be nice if you include a public proxy server for testing.

Options: ReplyQuote
Re: How to preconfigure proxy setting in custom KM build?
Posted by: rodocop
Date: November 01, 2017 02:00PM

Bravo, siria!

I'm stupid donkey again!

I've created wrong prefs again and again!

Instead
kmeleon.plugins.macros.proxy1.XXX
i've written
kmeleon.plugins.macros.proxy.proxy1.XXX

Now it works fine!



And I should attach my js-file with needed prefs - to be an example for next devs ;-)
Don't mention the PAC-file address - it only has sense to Russian citizens. This preconfigured proxy is used to circumvent our national restrictions (we are now almost like Chinese people in terms of free connectivity with outer world )

The code is here
pref("kmeleon.plugins.macros.proxy1.http.proxy.keep-alive", true);
pref("kmeleon.plugins.macros.proxy1.http.proxy.pipelining", false);
pref("kmeleon.plugins.macros.proxy1.http.proxy.version", "1.1");
pref("kmeleon.plugins.macros.proxy1.name", "VPN");
pref("kmeleon.plugins.macros.proxy1.proxy.autoconfig_url", "https://antizapret.prostovpn.org/proxy.pac";);
pref("kmeleon.plugins.macros.proxy1.proxy.ftp", "");
pref("kmeleon.plugins.macros.proxy1.proxy.ftp_port", 0);
pref("kmeleon.plugins.macros.proxy1.proxy.gopher", "");
pref("kmeleon.plugins.macros.proxy1.proxy.gopher_port", 0);
pref("kmeleon.plugins.macros.proxy1.proxy.http", "");
pref("kmeleon.plugins.macros.proxy1.proxy.http_port", 0);
pref("kmeleon.plugins.macros.proxy1.proxy.no_proxies_on", "localhost, 127.0.0.1");
pref("kmeleon.plugins.macros.proxy1.proxy.socks", "");
pref("kmeleon.plugins.macros.proxy1.proxy.socks_port", 0);
pref("kmeleon.plugins.macros.proxy1.proxy.socks_remote_dns", false);
pref("kmeleon.plugins.macros.proxy1.proxy.socks_version", 5);
pref("kmeleon.plugins.macros.proxy1.proxy.ssl", "");
pref("kmeleon.plugins.macros.proxy1.proxy.ssl_port", 0);
pref("kmeleon.plugins.macros.proxy1.proxy.type", 2);
pref("kmeleon.plugins.macros.proxy.configs", "proxy1;");


Latest Release KM75.1 Latest dev KM76RC ||| Visit The K-Meleon Place and join me there!
Old good stuff: KM-1.6db+NS © dugbugoffice // KM-16-S2014 © Fred // KM-1.6beta2.6 © JamesD // KM Twin+ © rodocop // KM 1.8.24.22 © adodupan

RECOMMENDED! K-Meleon 76 Pro ==» Download portable: 7zip or EXE =//= Discuss on forum
K-Meleon 75.1 Pro: Download =//= Discuss || Portable Flash plugin (x86/x64 DLLs)



Edited 3 time(s). Last edit at 11/01/2017 02:14PM by rodocop.

Attachments: antizapret.js (1.2 KB)  
Options: ReplyQuote
Re: How to preconfigure proxy setting in custom KM build?
Posted by: siria
Date: November 01, 2017 04:53PM

Glad you have the technical knowledge, that's a lot more difficult as just a little macrolang syntax smiling smiley

Yeah it's hard to bear seeing civilization getting destroyed all around the world again, all the time more downhill, and more, and more, everywhere - here too, just a few years behind yet in the global downhill race. But no hope anymore.

Options: ReplyQuote
Re: How to preconfigure proxy setting in custom KM build?
Posted by: Yogi
Date: November 11, 2017 09:29PM

@Rodocop

Only a minor marginal note -
speaking of privacy, wouldn't "proxy.socks_remote_dns" set tu true by default, be more appropriate since it is one of the main advantages of SOCKS 5 over SOCKS 4.

Options: ReplyQuote
Re: How to preconfigure proxy setting in custom KM build?
Posted by: rodocop
Date: November 12, 2017 01:23AM

Good point, Yogi! Thanks!


Latest Release KM75.1 Latest dev KM76RC ||| Visit The K-Meleon Place and join me there!
Old good stuff: KM-1.6db+NS © dugbugoffice // KM-16-S2014 © Fred // KM-1.6beta2.6 © JamesD // KM Twin+ © rodocop // KM 1.8.24.22 © adodupan

RECOMMENDED! K-Meleon 76 Pro ==» Download portable: 7zip or EXE =//= Discuss on forum
K-Meleon 75.1 Pro: Download =//= Discuss || Portable Flash plugin (x86/x64 DLLs)

Options: ReplyQuote


K-Meleon forum is powered by Phorum.