docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
if rateLimiter := Context.auth.raleLimiter; rateLimiter != nil {
if left := rateLimiter.check(remoteAddr); left > 0 { | <mask>
<mask> return
<mask> }
<mask>
<mask> if blocker := Context.auth.blocker; blocker != nil {
<mask> if left := blocker.check(remoteAddr); left > 0 {
<mask> w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds())))
<mask> aghhttp.Error(r, w, http.StatusTooManyRequests, "auth: blocked for... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
cookie, err := Context.auth.newCookie(req, remoteAddr) | <mask> return
<mask> }
<mask> }
<mask>
<mask> var cookie string
<mask> cookie, err = Context.auth.httpCookie(req, remoteAddr)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "crypto rand reader: %s", err)
<mask>
<mask> return
<mask> }
</s> Pull request: HOFTIX-csrf
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
aghhttp.Error(r, w, http.StatusForbidden, "%s", err) | <mask>
<mask> var cookie string
<mask> cookie, err = Context.auth.httpCookie(req, remoteAddr)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "crypto rand reader: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> // Use realIP here, since this IP address is only used f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
<mask> // Technically shouldn't happen.
<mask> log.Error("auth: unknown ip")
<mask> }
<mask>
<mask> if len(cookie) == 0 {
<mask> log.Info("auth: failed to login user %q from ip %v", req.Name, ip)
<mask>
<mask> time.Sleep(1 * time.Second)
<mask>
<mask> http.Error(w, "invalid username or password... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go | |
http.SetCookie(w, cookie)
| <mask> }
<mask>
<mask> log.Info("auth: user %q successfully logged in from ip %v", req.Name, ip)
<mask>
<mask> h := w.Header()
<mask> h.Set("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate")
<mask> h.Set("Pragma", "no-cache")
<mask> h.Set("Expires", "0")
<mask>
<mask> aghhttp.... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
<mask>
<mask> log.Info("auth: user %q successfully logged in from ip %v", req.Name, ip)
<mask>
<mask> h := w.Header()
<mask> h.Set("Set-Cookie", cookie)
<mask> h.Set("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate")
<mask> h.Set("Pragma", "no-cache")
<mask> h.Set("Expires", "0")
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go | |
respHdr := w.Header()
c, err := r.Cookie(sessionCookieName)
if err != nil {
// The only error that is returned from r.Cookie is [http.ErrNoCookie].
// The user is already logged out.
respHdr.Set("Location", "/login.html")
w.WriteHeader(http.StatusFound)
return
} | <mask> aghhttp.OK(w)
<mask> }
<mask>
<mask> func handleLogout(w http.ResponseWriter, r *http.Request) {
<mask> cookie := r.Header.Get("Cookie")
<mask> sess := parseCookie(cookie)
<mask>
<mask> Context.auth.RemoveSession(sess)
<mask>
<mask> w.Header().Set("Location", "/login.html")
<mask>
</s> Pull ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
Context.auth.RemoveSession(c.Value) | <mask> func handleLogout(w http.ResponseWriter, r *http.Request) {
<mask> cookie := r.Header.Get("Cookie")
<mask> sess := parseCookie(cookie)
<mask>
<mask> Context.auth.RemoveSession(sess)
<mask>
<mask> w.Header().Set("Location", "/login.html")
<mask>
<mask> s := fmt.Sprintf("%s=; Path=/; HttpOnly; Exp... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
c = &http.Cookie{
Name: sessionCookieName,
Value: "",
Path: "/",
Expires: time.Unix(0, 0), | <mask> sess := parseCookie(cookie)
<mask>
<mask> Context.auth.RemoveSession(sess)
<mask>
<mask> w.Header().Set("Location", "/login.html")
<mask>
<mask> s := fmt.Sprintf("%s=; Path=/; HttpOnly; Expires=Thu, 01 Jan 1970 00:00:00 GMT",
<mask> sessionCookieName)
<mask> w.Header().Set("Set-Cookie", s)
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
HttpOnly: true,
SameSite: http.SameSiteLaxMode,
} | <mask> Context.auth.RemoveSession(sess)
<mask>
<mask> w.Header().Set("Location", "/login.html")
<mask>
<mask> s := fmt.Sprintf("%s=; Path=/; HttpOnly; Expires=Thu, 01 Jan 1970 00:00:00 GMT",
<mask> sessionCookieName)
<mask> w.Header().Set("Set-Cookie", s)
<mask>
<mask> w.WriteHeader(http.StatusFound)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
respHdr.Set("Location", "/login.html")
respHdr.Set("Set-Cookie", c.String()) | <mask> SameSite: http.SameSiteLaxMode,
<mask> }
<mask>
<mask> w.WriteHeader(http.StatusFound)
<mask> }
<mask>
<mask> // RegisterAuthHandlers - register handlers
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
commit 75ab27bf6c52b80ab... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
<mask> Context.mux.Handle("/control/login", postInstallHandler(ensureHandler(http.MethodPost, handleLogin)))
<mask> httpRegister(http.MethodGet, "/control/logout", handleLogout)
<mask> }
<mask>
<mask> func parseCookie(cookie string) string {
<mask> pairs := strings.Split(cookie, ";")
<mask> for _, pair := r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go | |
func optionalAuthThird(w http.ResponseWriter, r *http.Request) (mustAuth bool) {
if glProcessCookie(r) {
log.Debug("auth: authentication is handled by GL-Inet submodule")
return false
} | <mask> return ""
<mask> }
<mask>
<mask> // optionalAuthThird return true if user should authenticate first.
<mask> func optionalAuthThird(w http.ResponseWriter, r *http.Request) (authFirst bool) {
<mask> authFirst = false
<mask>
<mask> // redirect to login page if not authenticated
<mask> ok := false
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
isAuthenticated := false | <mask> func optionalAuthThird(w http.ResponseWriter, r *http.Request) (authFirst bool) {
<mask> authFirst = false
<mask>
<mask> // redirect to login page if not authenticated
<mask> ok := false
<mask> cookie, err := r.Cookie(sessionCookieName)
<mask>
<mask> if glProcessCookie(r) {
<mask> log.Debug("au... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
if err != nil {
// The only error that is returned from r.Cookie is [http.ErrNoCookie].
// Check Basic authentication.
user, pass, hasBasic := r.BasicAuth()
if hasBasic {
_, isAuthenticated = Context.auth.findUser(user, pass)
if !isAuthenticated { | <mask>
<mask> // redirect to login page if not authenticated
<mask> ok := false
<mask> cookie, err := r.Cookie(sessionCookieName)
<mask>
<mask> if glProcessCookie(r) {
<mask> log.Debug("auth: authentication was handled by GL-Inet submodule")
<mask> ok = true
<mask> } else if err == nil {
<mask> r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
... | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
} else {
res := Context.auth.checkSession(cookie.Value)
isAuthenticated = res == checkSessionOK
if !isAuthenticated {
log.Debug("auth: invalid cookie value: %s", cookie)
} | <mask> log.Info("auth: invalid Basic Authorization value")
<mask> }
<mask> }
<mask> }
<mask>
<mask> if isAuthenticated {
<mask> return false
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
commit 75ab27bf6c52b80ab4e7347d7c254... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
if isAuthenticated {
return false
}
if p := r.URL.Path; p == "/" || p == "/index.html" {
if glProcessRedirect(w, r) {
log.Debug("auth: redirected to login page by GL-Inet submodule") | <mask> log.Info("auth: invalid Basic Authorization value")
<mask> }
<mask> }
<mask> }
<mask> if !ok {
<mask> if r.URL.Path == "/" || r.URL.Path == "/index.html" {
<mask> if glProcessRedirect(w, r) {
<mask> log.Debug("auth: redirected to login page by GL-Inet submodule")
<mask> } else {
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
log.Debug("auth: redirected to login page")
w.Header().Set("Location", "/login.html")
w.WriteHeader(http.StatusFound) | <mask> w.Header().Set("Location", "/login.html")
<mask> w.WriteHeader(http.StatusFound)
<mask> }
<mask> } else {
<mask> w.WriteHeader(http.StatusForbidden)
<mask> _, _ = w.Write([]byte("Forbidden"))
<mask> }
<mask> authFirst = true
<mask> }
<mask>
<mask> return authFirst
</s> Pull ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
} else {
log.Debug("auth: responded with forbidden to %s %s", r.Method, p)
w.WriteHeader(http.StatusForbidden)
_, _ = w.Write([]byte("Forbidden")) | <mask> } else {
<mask> w.WriteHeader(http.StatusForbidden)
<mask> _, _ = w.Write([]byte("Forbidden"))
<mask> }
<mask> authFirst = true
<mask> }
<mask>
<mask> return authFirst
<mask> }
<mask>
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
return true | <mask> }
<mask> authFirst = true
<mask> }
<mask>
<mask> return authFirst
<mask> }
<mask>
<mask> func optionalAuth(handler func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) {
<mask> return func(w http.ResponseWriter, r *http.Request) {
<mask> if r.URL.Path == "/login... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
// TODO(a.garipov): Use [http.Handler] consistently everywhere throughout the
// project.
func optionalAuth(
h func(http.ResponseWriter, *http.Request),
) (wrapped func(http.ResponseWriter, *http.Request)) { | <mask>
<mask> return authFirst
<mask> }
<mask>
<mask> func optionalAuth(handler func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) {
<mask> return func(w http.ResponseWriter, r *http.Request) {
<mask> if r.URL.Path == "/login.html" {
<mask> // redirect to dashboard if al... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
p := r.URL.Path
authRequired := Context.auth != nil && Context.auth.AuthRequired()
if p == "/login.html" { | <mask> }
<mask>
<mask> func optionalAuth(handler func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) {
<mask> return func(w http.ResponseWriter, r *http.Request) {
<mask> if r.URL.Path == "/login.html" {
<mask> // redirect to dashboard if already authenticated
<mask> auth... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
// Redirect to the dashboard if already authenticated.
res := Context.auth.checkSession(cookie.Value)
if res == checkSessionOK { | <mask> // redirect to dashboard if already authenticated
<mask> authRequired := Context.auth != nil && Context.auth.AuthRequired()
<mask> cookie, err := r.Cookie(sessionCookieName)
<mask> if authRequired && err == nil {
<mask> r := Context.auth.checkSession(cookie.Value)
<mask> if r == checkSe... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
<mask> w.Header().Set("Location", "/")
<mask> w.WriteHeader(http.StatusFound)
<mask>
<mask> return
<mask> } else if r == checkSessionNotFound {
<mask> log.Debug("auth: invalid cookie value: %s", cookie)
<mask> }
<mask> }
<mask>
<mask> } else if strings.HasPrefix(r.URL.Path, ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go | |
<mask> return
<mask> } else if r == checkSessionNotFound {
<mask> log.Debug("auth: invalid cookie value: %s", cookie)
<mask> }
<mask> }
<mask>
<mask> } else if strings.HasPrefix(r.URL.Path, "/assets/") ||
<mask> strings.HasPrefix(r.URL.Path, "/login.") {
<mask> // process as usual... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go | |
log.Debug("auth: invalid cookie value: %s", cookie)
}
} else if isPublicResource(p) {
// Process as usual, no additional auth requirements.
} else if authRequired { | <mask> log.Debug("auth: invalid cookie value: %s", cookie)
<mask> }
<mask> }
<mask>
<mask> } else if strings.HasPrefix(r.URL.Path, "/assets/") ||
<mask> strings.HasPrefix(r.URL.Path, "/login.") {
<mask> // process as usual
<mask> // no additional auth requirements
<mask> } else if Con... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
h(w, r) | <mask> return
<mask> }
<mask> }
<mask>
<mask> handler(w, r)
<mask> }
<mask> }
<mask>
<mask> type authHandler struct {
<mask> handler http.Handler
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
commit 75ab27bf6c52b80ab4e7... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
func (a *Auth) UserAdd(u *webUser, password string) { | <mask> return &authHandler{handler}
<mask> }
<mask>
<mask> // UserAdd - add new user
<mask> func (a *Auth) UserAdd(u *User, password string) {
<mask> if len(password) == 0 {
<mask> return
<mask> }
<mask>
<mask> hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
</s> Pull r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
// findUser returns a user if there is one.
func (a *Auth) findUser(login, password string) (u webUser, ok bool) { | <mask>
<mask> log.Debug("auth: added user: %s", u.Name)
<mask> }
<mask>
<mask> // UserFind - find a user
<mask> func (a *Auth) UserFind(login, password string) User {
<mask> a.lock.Lock()
<mask> defer a.lock.Unlock()
<mask> for _, u := range a.users {
<mask> if u.Name == login &&
<mask> bcrypt.Com... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
for _, u = range a.users { | <mask> // UserFind - find a user
<mask> func (a *Auth) UserFind(login, password string) User {
<mask> a.lock.Lock()
<mask> defer a.lock.Unlock()
<mask> for _, u := range a.users {
<mask> if u.Name == login &&
<mask> bcrypt.CompareHashAndPassword([]byte(u.PasswordHash), []byte(password)) == nil {
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
return u, true | <mask> defer a.lock.Unlock()
<mask> for _, u := range a.users {
<mask> if u.Name == login &&
<mask> bcrypt.CompareHashAndPassword([]byte(u.PasswordHash), []byte(password)) == nil {
<mask> return u
<mask> }
<mask> }
<mask> return User{}
<mask> }
<mask>
</s> Pull request: HOFTIX-csrf
Merge in D... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
return webUser{}, false | <mask> bcrypt.CompareHashAndPassword([]byte(u.PasswordHash), []byte(password)) == nil {
<mask> return u
<mask> }
<mask> }
<mask> return User{}
<mask> }
<mask>
<mask> // getCurrentUser returns the current user. It returns an empty User if the
<mask> // user is not found.
<mask> func (a *Auth) getCu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
func (a *Auth) getCurrentUser(r *http.Request) (u webUser) { | <mask> }
<mask>
<mask> // getCurrentUser returns the current user. It returns an empty User if the
<mask> // user is not found.
<mask> func (a *Auth) getCurrentUser(r *http.Request) User {
<mask> cookie, err := r.Cookie(sessionCookieName)
<mask> if err != nil {
<mask> // There's no Cookie, check Basic aut... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
u, _ = Context.auth.findUser(user, pass)
return u | <mask> if err != nil {
<mask> // There's no Cookie, check Basic authentication.
<mask> user, pass, ok := r.BasicAuth()
<mask> if ok {
<mask> return Context.auth.UserFind(user, pass)
<mask> }
<mask>
<mask> return User{}
<mask> }
<mask>
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
return webUser{} | <mask> if ok {
<mask> return Context.auth.UserFind(user, pass)
<mask> }
<mask>
<mask> return User{}
<mask> }
<mask>
<mask> a.lock.Lock()
<mask> defer a.lock.Unlock()
<mask>
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
return webUser{} | <mask> defer a.lock.Unlock()
<mask>
<mask> s, ok := a.sessions[cookie.Value]
<mask> if !ok {
<mask> return User{}
<mask> }
<mask>
<mask> for _, u := range a.users {
<mask> if u.Name == s.userName {
<mask> return u
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
for _, u = range a.users { | <mask> if !ok {
<mask> return User{}
<mask> }
<mask>
<mask> for _, u := range a.users {
<mask> if u.Name == s.userName {
<mask> return u
<mask> }
<mask> }
<mask>
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
commit 75ab... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
return webUser{} | <mask> return u
<mask> }
<mask> }
<mask>
<mask> return User{}
<mask> }
<mask>
<mask> // GetUsers - get users
<mask> func (a *Auth) GetUsers() []User {
<mask> a.lock.Lock()
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
commit... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
func (a *Auth) GetUsers() []webUser { | <mask> return User{}
<mask> }
<mask>
<mask> // GetUsers - get users
<mask> func (a *Auth) GetUsers() []User {
<mask> a.lock.Lock()
<mask> users := a.users
<mask> a.lock.Unlock()
<mask> return users
<mask> }
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
users := []webUser{{ | <mask> func TestAuth(t *testing.T) {
<mask> dir := t.TempDir()
<mask> fn := filepath.Join(dir, "sessions.db")
<mask>
<mask> users := []User{{
<mask> Name: "name",
<mask> PasswordHash: "$2y$05$..vyzAECIhJPfaQiOK17IukcQnqEgKJHy0iETyYqxn3YXJl8yZuo2",
<mask> }}
<mask> a := InitAuth(fn, nil, 60, n... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth_test.go |
user := webUser{Name: "name"} | <mask> }}
<mask> a := InitAuth(fn, nil, 60, nil)
<mask> s := session{}
<mask>
<mask> user := User{Name: "name"}
<mask> a.UserAdd(&user, "password")
<mask>
<mask> assert.Equal(t, checkSessionNotFound, a.checkSession("notfound"))
<mask> a.RemoveSession("notfound")
<mask>
</s> Pull request: HOFTIX-csr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth_test.go |
u, ok := a.findUser("name", "password")
assert.True(t, ok) | <mask> s.expire = uint32(time.Now().UTC().Unix() + 2)
<mask> a.storeSession(sess, &s)
<mask> a.Close()
<mask>
<mask> u := a.UserFind("name", "password")
<mask> assert.NotEmpty(t, u.Name)
<mask>
<mask> time.Sleep(3 * time.Second)
<mask>
<mask> // load and remove expired sessions
</s> Pull request: H... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth_test.go |
users := []webUser{ | <mask> func TestAuthHTTP(t *testing.T) {
<mask> dir := t.TempDir()
<mask> fn := filepath.Join(dir, "sessions.db")
<mask>
<mask> users := []User{
<mask> {Name: "name", PasswordHash: "$2y$05$..vyzAECIhJPfaQiOK17IukcQnqEgKJHy0iETyYqxn3YXJl8yZuo2"},
<mask> }
<mask> Context.auth = InitAuth(fn, users, 60, nil... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth_test.go |
cookie, err := Context.auth.newCookie(loginJSON{Name: "name", Password: "password"}, "") | <mask> handler2(&w, &r)
<mask> assert.True(t, handlerCalled)
<mask>
<mask> // perform login
<mask> cookie, err := Context.auth.httpCookie(loginJSON{Name: "name", Password: "password"}, "")
<mask> require.NoError(t, err)
<mask> assert.NotEmpty(t, cookie)
<mask>
<mask> // get /
<mask> handler2 = optio... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth_test.go |
require.NotNil(t, cookie) | <mask>
<mask> // perform login
<mask> cookie, err := Context.auth.httpCookie(loginJSON{Name: "name", Password: "password"}, "")
<mask> require.NoError(t, err)
<mask> assert.NotEmpty(t, cookie)
<mask>
<mask> // get /
<mask> handler2 = optionalAuth(handler)
<mask> w.hdr = make(http.Header)
<mask> r.He... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth_test.go |
r.Header.Set("Cookie", cookie.String()) | <mask>
<mask> // get /
<mask> handler2 = optionalAuth(handler)
<mask> w.hdr = make(http.Header)
<mask> r.Header.Set("Cookie", cookie)
<mask> r.URL = &url.URL{Path: "/"}
<mask> handlerCalled = false
<mask> handler2(&w, &r)
<mask> assert.True(t, handlerCalled)
<mask> r.Header.Del("Cookie")
</s> Pull ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth_test.go |
r.Header.Set("Cookie", cookie.String()) | <mask>
<mask> // get login page with a valid cookie - we're redirected to /
<mask> handler2 = optionalAuth(handler)
<mask> w.hdr = make(http.Header)
<mask> r.Header.Set("Cookie", cookie)
<mask> r.URL = &url.URL{Path: loginURL}
<mask> handlerCalled = false
<mask> handler2(&w, &r)
<mask> assert.NotEmpty... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth_test.go |
_ = aghhttp.WriteJSONResponse(w, r, data) | <mask> })
<mask>
<mask> data.Tags = clientTags
<mask>
<mask> w.Header().Set("Content-Type", "application/json")
<mask> e := json.NewEncoder(w).Encode(data)
<mask> if e != nil {
<mask> aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e)
<mask>
<mask> return
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/clientshttp.go |
_ = aghhttp.WriteJSONResponse(w, r, data) | <mask> idStr: cj,
<mask> })
<mask> }
<mask>
<mask> w.Header().Set("Content-Type", "application/json")
<mask> err := json.NewEncoder(w).Encode(data)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write response: %s", err)
<mask> }
<mask> }
<mask>
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/clientshttp.go |
BindHost net.IP `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
BetaBindPort int `yaml:"beta_bind_port"` // BetaBindPort is the port for new client
Users []webUser `yaml:"us... | <mask> // Raw file data to avoid re-reading of configuration file
<mask> // It's reset after config is parsed
<mask> fileData []byte
<mask>
<mask> BindHost net.IP `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
<mask> BindPort int `yaml:"bind_port"` // Bin... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/config.go |
_ = aghhttp.WriteJSONResponse(w, r, resp) | <mask> if runtime.GOOS != "windows" {
<mask> resp.IsDHCPAvailable = Context.dhcpServer != nil
<mask> }
<mask>
<mask> w.Header().Set("Content-Type", "application/json")
<mask> err = json.NewEncoder(w).Encode(resp)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusInternalServerError, "Unable... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/control.go |
aghhttp.Error(r, w, http.StatusMethodNotAllowed, "only %s is allowed", method)
| <mask> return func(w http.ResponseWriter, r *http.Request) {
<mask> log.Debug("%s %v", r.Method, r.URL)
<mask>
<mask> if r.Method != method {
<mask> http.Error(w, "This request must be "+method, http.StatusMethodNotAllowed)
<mask> return
<mask> }
<mask>
<mask> if method == http.MethodPost || m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/control.go |
if r.Header.Get(aghhttp.HdrNameContentType) != aghhttp.HdrValApplicationJSON {
aghhttp.Error(
r,
w,
http.StatusUnsupportedMediaType,
"only %s is allowed",
aghhttp.HdrValApplicationJSON,
)
return
}
| <mask>
<mask> if method == http.MethodPost || method == http.MethodPut || method == http.MethodDelete {
<mask> Context.controlLock.Lock()
<mask> defer Context.controlLock.Unlock()
<mask> }
<mask>
<mask> handler(w, r)
<mask> }
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/control.go |
_ = aghhttp.WriteJSONResponse(w, r, data) | <mask> for _, iface := range ifaces {
<mask> data.Interfaces[iface.Name] = iface
<mask> }
<mask>
<mask> w.Header().Set("Content-Type", "application/json")
<mask> err = json.NewEncoder(w).Encode(data)
<mask> if err != nil {
<mask> aghhttp.Error(
<mask> r,
<mask> w,
<mask> http.StatusInterna... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/controlinstall.go |
_ = aghhttp.WriteJSONResponse(w, r, resp) | <mask> } else if !req.DNS.IP.IsUnspecified() {
<mask> resp.StaticIP = handleStaticIP(req.DNS.IP, req.SetStaticIP)
<mask> }
<mask>
<mask> w.Header().Set("Content-Type", "application/json")
<mask> err = json.NewEncoder(w).Encode(resp)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusInternal... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/controlinstall.go |
u := &webUser{ | <mask>
<mask> return
<mask> }
<mask>
<mask> u := &User{
<mask> Name: req.Username,
<mask> }
<mask> Context.auth.UserAdd(u, req.Password)
<mask>
<mask> err = config.write()
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
comm... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/controlinstall.go |
_ = aghhttp.WriteJSONResponse(w, r, data) | <mask> }
<mask>
<mask> data.Interfaces = ifaces
<mask>
<mask> w.Header().Set("Content-Type", "application/json")
<mask> err = json.NewEncoder(w).Encode(data)
<mask> if err != nil {
<mask> aghhttp.Error(
<mask> r,
<mask> w,
<mask> http.StatusInternalServerError,
<mask> "Unable to marshal... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/controlinstall.go |
<mask> }
<mask>
<mask> // Get the latest available version from the Internet
<mask> func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) {
<mask> w.Header().Set("Content-Type", "application/json")
<mask>
<mask> resp := &versionResponse{}
<mask> if Context.disableUpdate {
<mask> resp.Disable... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/controlupdate.go | |
_ = aghhttp.WriteJSONResponse(w, r, resp) | <mask>
<mask> return
<mask> }
<mask>
<mask> err = json.NewEncoder(w).Encode(resp)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusInternalServerError, "writing body: %s", err)
<mask> }
<mask> }
<mask>
<mask> // requestVersionInfo sets the VersionInfo field of resp if it can reach the
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/controlupdate.go |
log.Info(version.Full()) | <mask> // configure log level and output
<mask> configureLogger(args)
<mask>
<mask> // Print the first message after logger is configured.
<mask> log.Println(version.Full())
<mask> log.Debug("current working directory is %s", Context.workDir)
<mask> if args.runningAsService {
<mask> log.Info("AdGuard H... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/home.go |
var rateLimiter *authRateLimiter | <mask> }
<mask>
<mask> sessFilename := filepath.Join(Context.getDataDir(), "sessions.db")
<mask> GLMode = args.glinetMode
<mask> var arl *authRateLimiter
<mask> if config.AuthAttempts > 0 && config.AuthBlockMin > 0 {
<mask> arl = newAuthRateLimiter(
<mask> time.Duration(config.AuthBlockMin)*time.Minu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/home.go |
rateLimiter = newAuthRateLimiter( | <mask> sessFilename := filepath.Join(Context.getDataDir(), "sessions.db")
<mask> GLMode = args.glinetMode
<mask> var arl *authRateLimiter
<mask> if config.AuthAttempts > 0 && config.AuthBlockMin > 0 {
<mask> arl = newAuthRateLimiter(
<mask> time.Duration(config.AuthBlockMin)*time.Minute,
<mask> confi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/home.go |
rateLimiter, | <mask> Context.auth = InitAuth(
<mask> sessFilename,
<mask> config.Users,
<mask> config.WebSessionTTLHours*60*60,
<mask> arl,
<mask> )
<mask> if Context.auth == nil {
<mask> log.Fatalf("Couldn't initialize Auth module")
<mask> }
<mask> config.Users = nil
</s> Pull request: HOFTIX-csrf
Merge i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/home.go |
"encoding/json" | <mask> package home
<mask>
<mask> import (
<mask> "fmt"
<mask> "io"
<mask> "net/http"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/golibs/log"
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
S... | [
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/i18n.go |
<mask> import (
<mask> "fmt"
<mask> "io"
<mask> "net/http"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/stringutil"
<mask> )
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-ho... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/i18n.go | |
// languageJSON is the JSON structure for language requests and responses.
type languageJSON struct {
Language string `json:"language"`
} | <mask> "zh-hk",
<mask> "zh-tw",
<mask> )
<mask>
<mask> func handleI18nCurrentLanguage(w http.ResponseWriter, _ *http.Request) {
<mask> w.Header().Set("Content-Type", "text/plain")
<mask> log.Printf("config.Language is %s", config.Language)
<mask> _, err := fmt.Fprintf(w, "%s\n", config.Language)
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/i18n.go |
func handleI18nCurrentLanguage(w http.ResponseWriter, r *http.Request) {
log.Printf("home: language is %s", config.Language)
_ = aghhttp.WriteJSONResponse(w, r, &languageJSON{
Language: config.Language,
}) | <mask> msg := fmt.Sprintf("Unable to write response json: %s", err)
<mask> log.Println(msg)
<mask> http.Error(w, msg, http.StatusInternalServerError)
<mask>
<mask> return
<mask> }
<mask> }
<mask>
<mask> func handleI18nChangeLanguage(w http.ResponseWriter, r *http.Request) {
<mask> // This use of R... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/i18n.go |
if aghhttp.WriteTextPlainDeprecated(w, r) { | <mask> }
<mask> }
<mask>
<mask> func handleI18nChangeLanguage(w http.ResponseWriter, r *http.Request) {
<mask> // This use of ReadAll is safe, because request's body is now limited.
<mask> body, err := io.ReadAll(r.Body)
<mask> if err != nil {
<mask> msg := fmt.Sprintf("failed to read request body: %s", ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/i18n.go |
langReq := &languageJSON{}
err := json.NewDecoder(r.Body).Decode(langReq)
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "reading req: %s", err) | <mask>
<mask> return
<mask> }
<mask>
<mask> language := strings.TrimSpace(string(body))
<mask> if language == "" {
<mask> msg := "empty language specified"
<mask> log.Println(msg)
<mask> http.Error(w, msg, http.StatusBadRequest)
<mask>
<mask> return
<mask> }
<mask>
<mask> if !allowedLan... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/i18n.go |
lang := langReq.Language
if !allowedLanguages.Has(lang) {
aghhttp.Error(r, w, http.StatusBadRequest, "unknown language: %q", lang) | <mask>
<mask> return
<mask> }
<mask>
<mask> if !allowedLanguages.Has(language) {
<mask> msg := fmt.Sprintf("unknown language specified: %s", language)
<mask> log.Println(msg)
<mask> http.Error(w, msg, http.StatusBadRequest)
<mask>
<mask> return
<mask> }
<mask>
<mask> func() {
</s> Pull r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/i18n.go |
config.Language = lang
log.Printf("home: language is set to %s", lang) | <mask> func() {
<mask> config.Lock()
<mask> defer config.Unlock()
<mask>
<mask> config.Language = language
<mask> }()
<mask>
<mask> onConfigModified()
<mask> aghhttp.OK(w)
<mask> }
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the followi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/i18n.go |
log.Info(version.Full())
log.Info("service: control action: %s", action) | <mask> // package. It's a noop for other GOOS values.
<mask> chooseSystem()
<mask>
<mask> action := opts.serviceControlAction
<mask> log.Printf("service: control action: %s", action)
<mask>
<mask> if action == "reload" {
<mask> sendSigReload()
<mask>
<mask> return
</s> Pull request: HOFTIX-csrf
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/service.go |
<mask> return data, nil
<mask> }
<mask>
<mask> func marshalTLS(w http.ResponseWriter, r *http.Request, data tlsConfig) {
<mask> w.Header().Set("Content-Type", "application/json")
<mask>
<mask> if data.CertificateChain != "" {
<mask> encoded := base64.StdEncoding.EncodeToString([]byte(data.CertificateChai... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/tls.go | |
_ = aghhttp.WriteJSONResponse(w, r, data) | <mask> data.PrivateKeySaved = true
<mask> data.PrivateKey = ""
<mask> }
<mask>
<mask> err := json.NewEncoder(w).Encode(data)
<mask> if err != nil {
<mask> aghhttp.Error(
<mask> r,
<mask> w,
<mask> http.StatusInternalServerError,
<mask> "Failed to marshal json with TLS status: %s",
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/tls.go |
u := webUser{ | <mask> if err != nil {
<mask> log.Fatalf("Can't use password \"%s\": bcrypt.GenerateFromPassword: %s", passStr, err)
<mask> return nil
<mask> }
<mask> u := User{
<mask> Name: nameStr,
<mask> PasswordHash: string(hash),
<mask> }
<mask> users := []User{u}
<mask> diskConf["users"] = users
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/upgrade.go |
users := []webUser{u} | <mask> u := User{
<mask> Name: nameStr,
<mask> PasswordHash: string(hash),
<mask> }
<mask> users := []User{u}
<mask> diskConf["users"] = users
<mask> return nil
<mask> }
<mask>
<mask> // clients:
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/upgrade.go |
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/DhcpFindActiveReq' | <mask> 'tags':
<mask> - 'dhcp'
<mask> 'operationId': 'checkActiveDhcp'
<mask> 'summary': 'Searches for an active DHCP server on the network'
<mask> 'responses':
<mask> '200':
<mask> 'description': 'OK.'
<mask> 'content':
<mask> 'application/... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | openapi/openapi.yaml |
<mask> 'tags':
<mask> - 'parental'
<mask> 'operationId': 'parentalEnable'
<mask> 'summary': 'Enable parental filtering'
<mask> 'requestBody':
<mask> 'content':
<mask> 'text/plain':
<mask> 'schema':
<mask> 'type': 'string'
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"k... | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | openapi/openapi.yaml | |
'application/json': | <mask> 'summary': >
<mask> Change current language. Argument must be an ISO 639-1 two-letter code.
<mask> 'requestBody':
<mask> 'content':
<mask> 'text/plain':
<mask> 'schema':
<mask> 'type': 'string'
<mask> 'example': 'en'
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | openapi/openapi.yaml |
'$ref': '#/components/schemas/LanguageSettings' | <mask> 'requestBody':
<mask> 'content':
<mask> 'text/plain':
<mask> 'schema':
<mask> 'type': 'string'
<mask> 'example': 'en'
<mask> 'description': >
<mask> New language. It must be known to the server and must be an ISO 639-1
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | openapi/openapi.yaml |
'application/json':
'schema':
'$ref': '#/components/schemas/LanguageSettings' | <mask> 'responses':
<mask> '200':
<mask> 'description': 'OK.'
<mask> 'content':
<mask> 'text/plain':
<mask> 'examples':
<mask> 'response':
<mask> 'value': 'en'
<mask> '/install/get_addresses_beta':
<mask> 'get'... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | openapi/openapi.yaml |
'DhcpFindActiveReq':
'description': >
Request for checking for other DHCP servers in the network.
'properties':
'interface':
'description': 'The name of the network interface'
'example': 'eth0'
'type': 'string'
'type': 'object'
| <mask> '$ref': '#/components/schemas/NetInterface'
<mask>
<mask> 'DhcpSearchResult':
<mask> 'type': 'object'
<mask> 'description': >
<mask> Information about a DHCP server discovered in the current network.
<mask> 'properties':
</s> Pull request: HOFTIX-csrf
Merge in DNS/... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | openapi/openapi.yaml |
'LanguageSettings':
'description': 'Language settings object.'
'properties':
'language':
'description': 'The current language or the language to set.'
'type': 'string'
'required':
- 'language'
'type': 'object' | <mask> 'message':
<mask> 'description': 'The error message, an opaque string.'
<mask> 'type': 'string'
<mask> 'type': 'object'
<mask> 'securitySchemes':
<mask> 'basicAuth':
<mask> 'type': 'http'
<mask> 'scheme': 'basic'
</s> Pull request: HOFTIX-csrf
Merge i... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | openapi/openapi.yaml |
"bootstrap_dns_desc": "Bootstrap DNS servers are used to resolve IP addresses of the DOH/DOT resolvers you specify as upstreams.",
"setup_guide": "Setup guide",
"dns_addresses": "DNS addresses" | <mask> "reset_settings": "Reset settings",
<mask> "update_announcement": "AdGuard Home {{version}} is now available! <0>Click here</0> for more info.",
<mask> "upstream_parallel": "Use parallel queries to speed up resolving by simultaneously querying all upstream servers",
<mask> "bootstrap_dns": "B... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/__locales/en.json |
import SetupGuide from '../../containers/SetupGuide'; | <mask> import Dashboard from '../../containers/Dashboard';
<mask> import Settings from '../../containers/Settings';
<mask> import Filters from '../../containers/Filters';
<mask> import Logs from '../../containers/Logs';
<mask> import Footer from '../ui/Footer';
<mask> import Toasts from '../Toasts';
<mask> impor... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/App/index.js |
import Footer from '../ui/Footer'; | <mask> import Filters from '../../containers/Filters';
<mask> import Logs from '../../containers/Logs';
<mask> import SetupGuide from '../../containers/SetupGuide';
<mask> import Toasts from '../Toasts';
<mask> import Status from '../ui/Status';
<mask> import UpdateTopline from '../ui/UpdateTopline';
<mask> impo... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/App/index.js |
<Route path="/guide" component={SetupGuide} /> | <mask> <Route path="/settings" component={Settings} />
<mask> <Route path="/filters" component={Filters} />
<mask> <Route path="/logs" component={Logs} />
<mask> </Fragment>
<mask> ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/App/index.js |
.nav-version__link {
position: relative;
display: inline-block;
border-bottom: 1px dashed #495057;
cursor: pointer;
}
| <mask> }
<mask>
<mask> .header-brand-img {
<mask> height: 32px;
<mask> }
<mask>
</s> + client: added setup guide page and DNS addresses popover
Closes #605 </s> remove <div className="col col-sm-6 col-lg-3">
<Version
{ ...... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/Header/Header.css |
<mask> import PropTypes from 'prop-types';
<mask> import enhanceWithClickOutside from 'react-click-outside';
<mask> import classnames from 'classnames';
<mask> import { Trans, withNamespaces } from 'react-i18next';
<mask> import { REPOSITORY } from '../../helpers/constants';
<mask>
<mask> class Menu extends Com... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/Header/Menu.js | |
<NavLink to="/guide" href="/guide" className="nav-link"> | <mask> <Trans>query_log</Trans>
<mask> </NavLink>
<mask> </li>
<mask> <li className="nav-item">
<mask> <a href={`${REPOSITORY.URL}/wiki`} className="nav-link" target="_blank" rel=... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/Header/Menu.js |
<Trans>setup_guide</Trans>
</NavLink> | <mask> </li>
<mask> <li className="nav-item">
<mask> <a href={`${REPOSITORY.URL}/wiki`} className="nav-link" target="_blank" rel="noopener noreferrer">
<mask> <svg className="nav-icon" xmlns="http://www.w3.or... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/Header/Menu.js |
import { getDnsAddress } from '../../helpers/helpers';
| <mask> import PropTypes from 'prop-types';
<mask> import { Trans, withNamespaces } from 'react-i18next';
<mask>
<mask> function Version(props) {
<mask> const { dnsVersion, dnsAddresses, dnsPort } = props;
<mask> return (
<mask> <div className="nav-version">
</s> + client: added setup guide page... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/Header/Version.js |
const { dnsVersion, dnsAddresses, dnsPort } = props; | <mask> import PropTypes from 'prop-types';
<mask> import { Trans, withNamespaces } from 'react-i18next';
<mask>
<mask> function Version(props) {
<mask> const { dnsVersion, dnsAddress, dnsPort } = props;
<mask> return (
<mask> <div className="nav-version">
<mask> <div className="nav-... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/Header/Version.js |
<div className="nav-version__link">
<div className="popover__trigger popover__trigger--address">
<Trans>dns_addresses</Trans>
</div>
<div className="popover__body popover__body--address">
<div className="popover__list">
... | <mask> <div className="nav-version">
<mask> <div className="nav-version__text">
<mask> <Trans>version</Trans>: <span className="nav-version__value">{dnsVersion}</span>
<mask> </div>
<mask> <div className="nav-version__text">
<mask> <Trans... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/Header/Version.js |
dnsVersion: PropTypes.string.isRequired,
dnsAddresses: PropTypes.array.isRequired,
dnsPort: PropTypes.number.isRequired, | <mask> );
<mask> }
<mask>
<mask> Version.propTypes = {
<mask> dnsVersion: PropTypes.string,
<mask> dnsAddress: PropTypes.string,
<mask> dnsPort: PropTypes.number,
<mask> };
<mask>
<mask> export default withNamespaces()(Version);
</s> + client: added setup guide page and DNS addresses popove... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/Header/Version.js |
{!dashboard.processing &&
<div className="col col-sm-6 col-lg-3">
<Version
{ ...this.props.dashboard }
/>
</div>
} | <mask> isMenuOpen={isMenuOpen}
<mask> toggleMenuOpen={this.toggleMenuOpen}
<mask> closeMenu={this.closeMenu}
<mask> />
<mask> <div className="col col-sm-6 col-lg-3">
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/Header/index.js |
.popover__trigger--address {
top: 0;
margin: 0;
line-height: 1.2;
}
.popover__trigger--address:after {
display: none;
}
| <mask> }
<mask>
<mask> .popover__body {
<mask> content: "";
<mask> display: flex;
<mask> position: absolute;
<mask> bottom: calc(100% + 3px);
<mask> left: 50%;
</s> + client: added setup guide page and DNS addresses popover
Closes #605 </s> remove const { dnsVersion, dnsAddress, dnsPo... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/ui/Popover.css |
.popover__list--bold {
font-weight: 700;
}
| <mask> stroke: #66b574;
<mask> }
<mask>
<mask> .popover__list-title {
<mask> margin-bottom: 3px;
<mask> }
<mask>
<mask> .popover__list-item {
<mask> margin-bottom: 2px;
</s> + client: added setup guide page and DNS addresses popover
Closes #605 </s> remove const { dnsVersion, dnsAddress, dn... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/components/ui/Popover.css |
import Guide from '../../components/ui/Guide'; | <mask> import { reduxForm, formValueSelector } from 'redux-form';
<mask> import { Trans, withNamespaces } from 'react-i18next';
<mask> import flow from 'lodash/flow';
<mask>
<mask> import Tabs from '../../components/ui/Tabs';
<mask> import Icons from '../../components/ui/Icons';
<mask> import Controls from './C... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/install/Setup/Devices.js |
<Guide /> | <mask> isDns={true}
<mask> />
<mask> </div>
<mask> </div>
<mask> <Icons />
<mask> <Tabs>
<mask> <div label="Router">
<mask> <div className="tab__title">
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/AdguardTeam/AdGuardHome/commit/756c5ac0d3c9b685f95cc755ad098cef74e0c517 | client/src/install/Setup/Devices.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.