freedom noise

Co-Authored-By: mhsanaei <ho3ein.sanaei@gmail.com>
This commit is contained in:
Alireza Ahmadi
2024-09-01 11:34:52 +02:00
parent c6fb39ab29
commit a9f295e4c6
9 changed files with 105 additions and 5 deletions

View File

@@ -824,23 +824,34 @@ Outbound.Settings = class extends CommonClass {
}
};
Outbound.FreedomSettings = class extends CommonClass {
constructor(domainStrategy='', fragment={}) {
constructor(
domainStrategy = '',
redirect = '',
fragment = {},
noise = {}
) {
super();
this.domainStrategy = domainStrategy;
this.redirect = redirect;
this.fragment = fragment;
this.noise = noise;
}
static fromJson(json={}) {
static fromJson(json = {}) {
return new Outbound.FreedomSettings(
json.domainStrategy,
json.redirect,
json.fragment ? Outbound.FreedomSettings.Fragment.fromJson(json.fragment) : undefined,
json.noise ? Outbound.FreedomSettings.Noise.fromJson(json.noise) : undefined,
);
}
toJson() {
return {
domainStrategy: ObjectUtil.isEmpty(this.domainStrategy) ? undefined : this.domainStrategy,
redirect: this.redirect,
fragment: Object.keys(this.fragment).length === 0 ? undefined : this.fragment,
noise: Object.keys(this.noise).length === 0 ? undefined : this.noise,
};
}
};
@@ -860,6 +871,20 @@ Outbound.FreedomSettings.Fragment = class extends CommonClass {
);
}
};
Outbound.FreedomSettings.Noise = class extends CommonClass {
constructor(packets = '', delay = '') {
super();
this.packets = packets;
this.delay = delay;
}
static fromJson(json = {}) {
return new Outbound.FreedomSettings.Noise(
json.packets,
json.delay,
);
}
};
Outbound.BlackholeSettings = class extends CommonClass {
constructor(type) {
super();