Skip to content

Commit

Permalink
Merge pull request #1315 from getlantern/feature-google-ads
Browse files Browse the repository at this point in the history
Added google ads flag in features
  • Loading branch information
atavism authored Aug 30, 2023
2 parents 1496fa0 + 5d5426c commit 5ce2352
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const (
FeatureOtel = "otel"
FeatureP2PFreePeer = "p2pfreepeer"
FeatureP2PCensoredPeer = "p2pcensoredpeer"
FeatureInterstitialAds = "interstitialads"
FeatureCASInterstitialAds = "casinterstitialads"
)

var (
Expand Down
16 changes: 16 additions & 0 deletions config/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@ func TestOtelEnabled(t *testing.T) {
assert.True(t, gl.FeatureEnabled(FeatureOtel, "android", common.DefaultAppName, "7.0.0", 500, false, "ae"), "Otel is enabled for high user in UAE")
}

func TestInterstitialAdsEnabled(t *testing.T) {
gl := globalFromTemplate(t)
assert.True(t, gl.FeatureEnabled(FeatureInterstitialAds, "android", common.DefaultAppName, "7.0.0", 1, false, "in"), "Interstitial ads are enabled in India")
assert.False(t, gl.FeatureEnabled(FeatureInterstitialAds, "android", common.DefaultAppName, "7.0.0", 1, false, "cn"), "Interstitial ads are disabled in China")
assert.False(t, gl.FeatureEnabled(FeatureInterstitialAds, "windows", common.DefaultAppName, "7.0.0", 1, false, "in"), "Interstitial ads are disabled on Windows")
assert.False(t, gl.FeatureEnabled(FeatureInterstitialAds, "android", common.DefaultAppName, "7.0.0", 1, false, "ru"), "Interstitial ads are disable in Russia")

}
func TestCASInterstitialAdsEnabled(t *testing.T) {
gl := globalFromTemplate(t)
assert.False(t, gl.FeatureEnabled(FeatureCASInterstitialAds, "android", common.DefaultAppName, "7.0.0", 1, false, "in"), "CASInterstitial ads are disable in India")
assert.False(t, gl.FeatureEnabled(FeatureCASInterstitialAds, "android", common.DefaultAppName, "7.0.0", 1, false, "cn"), "CASInterstitial ads are disable in China")
assert.True(t, gl.FeatureEnabled(FeatureCASInterstitialAds, "android", common.DefaultAppName, "7.0.0", 1, false, "ru"), "CASInterstitial ads are enable in Russia")
assert.False(t, gl.FeatureEnabled(FeatureCASInterstitialAds, "windows", common.DefaultAppName, "7.0.0", 1, false, "in"), "CASInterstitial ads are disabled on Windows")
}

func requireGetReplicaOptionsRoot(t *testing.T) (fos replicaConfig.ReplicaOptionsRoot) {
var g globalConfig.Raw
err := embeddedconfig.ExecuteAndUnmarshalGlobal(nil, &g)
Expand Down
8 changes: 8 additions & 0 deletions embeddedconfig/global.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ reportissueemail: [email protected]
#

featuresenabled:
casinterstitialads:
- label: show-cas-interstitial-ads
geocountries: ru,ir
platforms: android
interstitialads:
- label: show-interstitial-ads
geocountries: af,ax,al,dz,as,ad,ao,ai,aq,ag,ar,am,aw,au,at,az,bs,bh,bd,bb,by,be,bz,bj,bm,bt,bo,bq,ba,bw,bv,br,io,bn,bg,bf,bi,cv,kh,cm,ca,ky,cf,td,cl,cx,cc,co,km,cg,cd,ck,cr,hr,cu,cw,cy,cz,dk,dj,dm,do,ec,eg,sv,gq,er,ee,sz,et,fk,fo,fj,fi,fr,gf,pf,tf,ga,gm,ge,de,gh,gi,gr,gl,gd,gp,gu,gt,gg,gn,gw,gy,ht,hm,va,hn,hu,is,in,id,iq,ie,im,il,it,jm,jp,je,jo,kz,ke,ki,kp,kr,kw,kg,la,lv,lb,ls,lr,ly,li,lt,lu,mo,mg,mw,my,mv,ml,mt,mh,mq,mr,mu,yt,mx,fm,md,mc,mn,me,ms,ma,mz,mm,na,nr,np,nl,nc,nz,ni,ne,ng,nu,nf,mk,mp,no,om,pk,pw,ps,pa,pg,py,pe,ph,pn,pl,pt,pr,qa,re,ro,rw,bl,sh,kn,lc,mf,pm,vc,ws,sm,st,sa,sn,rs,sc,sl,sg,sx,sk,si,sb,so,za,gs,ss,es,lk,sd,sr,sj,se,ch,sy,tw,tj,tz,th,tl,tg,tk,to,tt,tn,tr,tm,tc,tv,ug,ua,ae,gb,us,um,uy,uz,vu,ve,vn,vg,vi,wf,eh,ye,zm,zw
platforms: android
p2pfreepeer:
- label: p2pfreepeer-desktop
application: lantern
Expand Down
2 changes: 0 additions & 2 deletions genconfig/genconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ var (
blacklist = make(filter)
proxiedSites = make(filter)
ftVersion string
showAds = false

inputCh = make(chan string)
masqueradesCh = make(chan *masquerade)
Expand Down Expand Up @@ -540,7 +539,6 @@ func buildModel(configDir string, configName string, cas map[string]*castat) (ma
"cloudfrontMasquerades": cfMasquerades,
"providers": enabledProviders,
"proxiedsites": ps,
"showAds": showAds,
"ftVersion": ftVersion,
}, nil
}
Expand Down

0 comments on commit 5ce2352

Please sign in to comment.