docstring_tokens
stringlengths 0
76.5k
| code_tokens
stringlengths 75
1.81M
| label_window
sequencelengths 4
2.12k
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|---|
testutil.AssertErrorMsg(t, "addr has an unexpected type *dhcpd.unexpectedAddrType", err) | <mask> conn := &dhcpConn{}
<mask> n, err := conn.WriteTo(nil, &unexpectedAddrType{})
<mask> require.Error(t, err)
<mask>
<mask> testutil.AssertErrorMsg(t, "peer is of unexpected type *dhcpd.unexpectedAddrType", err)
<mask> assert.Zero(t, n)
<mask> })
<mask> }
<mask>
<mask> func TestBuildEtherPkt(t *testing.T) {
</s> Pull request: 4337 increase msg size
Merge in DNS/adguard-home from 4337-dhcp-msg-len to master
Updates #4337.
Squashed commit of the following:
commit 55e53c1fadd4ccb2a8b94117afff82e9a5d2734b
Merge: f37070ea da1ae338
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 14:14:21 2022 +0300
Merge branch 'master' into 4337-dhcp-msg-len
commit f37070ea0f3a7ff8efcbbafd36001f78d9b082b5
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 13:15:25 2022 +0300
dhcpd: imp ether pkt building
commit fa43a0bcc24d4ca5e9193899dbba8495f3de5df9
Author: Eugene Burkov <[email protected]>
Date: Tue Sep 6 18:55:07 2022 +0300
dhcpd: incr msg size </s> remove t.Run("non-serializable", func(t *testing.T) {
</s> add t.Run("bad_payload", func(t *testing.T) { </s> remove return 0, fmt.Errorf("peer is of unexpected type %T", addr)
</s> add return 0, fmt.Errorf("addr has an unexpected type %T", addr) </s> remove pkt, err := conn.buildEtherPkt(invalidPayload, nil)
require.Error(t, err)
</s> add pkt, err := conn.buildEtherPkt(invalidPayload, peer)
require.NoError(t, err) </s> remove assert.ErrorIs(t, err, errInvalidPktDHCP)
assert.Empty(t, pkt)
</s> add assert.NotEmpty(t, pkt) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53209bc42c2401e017e5b727fb74272953a8cd0e | internal/dhcpd/conn_unix_test.go |
t.Run("bad_payload", func(t *testing.T) { | <mask> assert.Equal(t, wantType, layer.LayerType())
<mask> }
<mask> })
<mask>
<mask> t.Run("non-serializable", func(t *testing.T) {
<mask> // Create an invalid DHCP packet.
<mask> invalidPayload := []byte{1, 2, 3, 4}
<mask> pkt, err := conn.buildEtherPkt(invalidPayload, nil)
<mask> require.Error(t, err)
<mask>
</s> Pull request: 4337 increase msg size
Merge in DNS/adguard-home from 4337-dhcp-msg-len to master
Updates #4337.
Squashed commit of the following:
commit 55e53c1fadd4ccb2a8b94117afff82e9a5d2734b
Merge: f37070ea da1ae338
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 14:14:21 2022 +0300
Merge branch 'master' into 4337-dhcp-msg-len
commit f37070ea0f3a7ff8efcbbafd36001f78d9b082b5
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 13:15:25 2022 +0300
dhcpd: imp ether pkt building
commit fa43a0bcc24d4ca5e9193899dbba8495f3de5df9
Author: Eugene Burkov <[email protected]>
Date: Tue Sep 6 18:55:07 2022 +0300
dhcpd: incr msg size </s> remove pkt, err := conn.buildEtherPkt(invalidPayload, nil)
require.Error(t, err)
</s> add pkt, err := conn.buildEtherPkt(invalidPayload, peer)
require.NoError(t, err) </s> remove assert.ErrorIs(t, err, errInvalidPktDHCP)
assert.Empty(t, pkt)
</s> add assert.NotEmpty(t, pkt) </s> remove testutil.AssertErrorMsg(t, "peer is of unexpected type *dhcpd.unexpectedAddrType", err)
</s> add testutil.AssertErrorMsg(t, "addr has an unexpected type *dhcpd.unexpectedAddrType", err) </s> remove log.Debug("dhcpv4: sending to %s: %s", peer, resp.Summary())
if _, err := conn.WriteTo(resp.ToBytes(), peer); err != nil {
</s> add pktData := resp.ToBytes()
pktLen := len(pktData)
if pktLen < minDHCPMsgSize {
// Expand the packet to match the minimum DHCP message length. Although
// the dhpcv4 package deals with the BOOTP's lower packet length
// constraint, it seems some clients expecting the length being at least
// 576 bytes as per RFC 2131 (and an obsolete RFC 1533).
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/4337.
pktData = append(pktData, make([]byte, minDHCPMsgSize-pktLen)...)
}
log.Debug("dhcpv4: sending %d bytes to %s: %s", len(pktData), peer, resp.Summary())
_, err := conn.WriteTo(pktData, peer)
if err != nil { </s> remove dhcpLayer := gopacket.NewPacket(payload, layers.LayerTypeDHCPv4, gopacket.DecodeOptions{
NoCopy: true,
}).Layer(layers.LayerTypeDHCPv4)
// Check if the decoding succeeded and the resulting layer doesn't
// contain any errors. It should guarantee panic-safe converting of the
// layer into gopacket.SerializableLayer.
if dhcpLayer == nil || dhcpLayer.LayerType() != layers.LayerTypeDHCPv4 {
return nil, errInvalidPktDHCP
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53209bc42c2401e017e5b727fb74272953a8cd0e | internal/dhcpd/conn_unix_test.go |
pkt, err := conn.buildEtherPkt(invalidPayload, peer)
require.NoError(t, err) | <mask>
<mask> t.Run("non-serializable", func(t *testing.T) {
<mask> // Create an invalid DHCP packet.
<mask> invalidPayload := []byte{1, 2, 3, 4}
<mask> pkt, err := conn.buildEtherPkt(invalidPayload, nil)
<mask> require.Error(t, err)
<mask>
<mask> assert.ErrorIs(t, err, errInvalidPktDHCP)
<mask> assert.Empty(t, pkt)
<mask> })
<mask>
</s> Pull request: 4337 increase msg size
Merge in DNS/adguard-home from 4337-dhcp-msg-len to master
Updates #4337.
Squashed commit of the following:
commit 55e53c1fadd4ccb2a8b94117afff82e9a5d2734b
Merge: f37070ea da1ae338
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 14:14:21 2022 +0300
Merge branch 'master' into 4337-dhcp-msg-len
commit f37070ea0f3a7ff8efcbbafd36001f78d9b082b5
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 13:15:25 2022 +0300
dhcpd: imp ether pkt building
commit fa43a0bcc24d4ca5e9193899dbba8495f3de5df9
Author: Eugene Burkov <[email protected]>
Date: Tue Sep 6 18:55:07 2022 +0300
dhcpd: incr msg size </s> remove assert.ErrorIs(t, err, errInvalidPktDHCP)
assert.Empty(t, pkt)
</s> add assert.NotEmpty(t, pkt) </s> remove t.Run("non-serializable", func(t *testing.T) {
</s> add t.Run("bad_payload", func(t *testing.T) { </s> remove testutil.AssertErrorMsg(t, "peer is of unexpected type *dhcpd.unexpectedAddrType", err)
</s> add testutil.AssertErrorMsg(t, "addr has an unexpected type *dhcpd.unexpectedAddrType", err) </s> remove log.Debug("dhcpv4: sending to %s: %s", peer, resp.Summary())
if _, err := conn.WriteTo(resp.ToBytes(), peer); err != nil {
</s> add pktData := resp.ToBytes()
pktLen := len(pktData)
if pktLen < minDHCPMsgSize {
// Expand the packet to match the minimum DHCP message length. Although
// the dhpcv4 package deals with the BOOTP's lower packet length
// constraint, it seems some clients expecting the length being at least
// 576 bytes as per RFC 2131 (and an obsolete RFC 1533).
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/4337.
pktData = append(pktData, make([]byte, minDHCPMsgSize-pktLen)...)
}
log.Debug("dhcpv4: sending %d bytes to %s: %s", len(pktData), peer, resp.Summary())
_, err := conn.WriteTo(pktData, peer)
if err != nil { </s> remove dhcpLayer := gopacket.NewPacket(payload, layers.LayerTypeDHCPv4, gopacket.DecodeOptions{
NoCopy: true,
}).Layer(layers.LayerTypeDHCPv4)
// Check if the decoding succeeded and the resulting layer doesn't
// contain any errors. It should guarantee panic-safe converting of the
// layer into gopacket.SerializableLayer.
if dhcpLayer == nil || dhcpLayer.LayerType() != layers.LayerTypeDHCPv4 {
return nil, errInvalidPktDHCP
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53209bc42c2401e017e5b727fb74272953a8cd0e | internal/dhcpd/conn_unix_test.go |
assert.NotEmpty(t, pkt) | <mask> invalidPayload := []byte{1, 2, 3, 4}
<mask> pkt, err := conn.buildEtherPkt(invalidPayload, nil)
<mask> require.Error(t, err)
<mask>
<mask> assert.ErrorIs(t, err, errInvalidPktDHCP)
<mask> assert.Empty(t, pkt)
<mask> })
<mask>
<mask> t.Run("serializing_error", func(t *testing.T) {
<mask> // Create a peer with invalid MAC.
<mask> badPeer := &dhcpUnicastAddr{
</s> Pull request: 4337 increase msg size
Merge in DNS/adguard-home from 4337-dhcp-msg-len to master
Updates #4337.
Squashed commit of the following:
commit 55e53c1fadd4ccb2a8b94117afff82e9a5d2734b
Merge: f37070ea da1ae338
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 14:14:21 2022 +0300
Merge branch 'master' into 4337-dhcp-msg-len
commit f37070ea0f3a7ff8efcbbafd36001f78d9b082b5
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 13:15:25 2022 +0300
dhcpd: imp ether pkt building
commit fa43a0bcc24d4ca5e9193899dbba8495f3de5df9
Author: Eugene Burkov <[email protected]>
Date: Tue Sep 6 18:55:07 2022 +0300
dhcpd: incr msg size </s> remove pkt, err := conn.buildEtherPkt(invalidPayload, nil)
require.Error(t, err)
</s> add pkt, err := conn.buildEtherPkt(invalidPayload, peer)
require.NoError(t, err) </s> remove t.Run("non-serializable", func(t *testing.T) {
</s> add t.Run("bad_payload", func(t *testing.T) { </s> remove testutil.AssertErrorMsg(t, "peer is of unexpected type *dhcpd.unexpectedAddrType", err)
</s> add testutil.AssertErrorMsg(t, "addr has an unexpected type *dhcpd.unexpectedAddrType", err) </s> remove log.Debug("dhcpv4: sending to %s: %s", peer, resp.Summary())
if _, err := conn.WriteTo(resp.ToBytes(), peer); err != nil {
</s> add pktData := resp.ToBytes()
pktLen := len(pktData)
if pktLen < minDHCPMsgSize {
// Expand the packet to match the minimum DHCP message length. Although
// the dhpcv4 package deals with the BOOTP's lower packet length
// constraint, it seems some clients expecting the length being at least
// 576 bytes as per RFC 2131 (and an obsolete RFC 1533).
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/4337.
pktData = append(pktData, make([]byte, minDHCPMsgSize-pktLen)...)
}
log.Debug("dhcpv4: sending %d bytes to %s: %s", len(pktData), peer, resp.Summary())
_, err := conn.WriteTo(pktData, peer)
if err != nil { </s> remove // errInvalidPktDHCP is returned when the provided payload is not a valid DHCP
// packet.
const errInvalidPktDHCP errors.Error = "packet is not a valid dhcp packet"
// buildEtherPkt wraps the payload with IPv4, UDP and Ethernet frames. The
// payload is expected to be an encoded DHCP packet.
</s> add // buildEtherPkt wraps the payload with IPv4, UDP and Ethernet frames.
// Validation of the payload is a caller's responsibility. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53209bc42c2401e017e5b727fb74272953a8cd0e | internal/dhcpd/conn_unix_test.go |
// minDHCPMsgSize is the minimum length of the encoded DHCP message in bytes
// according to RFC-2131.
//
// See https://datatracker.ietf.org/doc/html/rfc2131#section-2.
const minDHCPMsgSize = 576
| <mask> }
<mask>
<mask> // send writes resp for peer to conn considering the req's parameters according
<mask> // to RFC-2131.
<mask> //
<mask> // See https://datatracker.ietf.org/doc/html/rfc2131#section-4.1.
<mask> func (s *v4Server) send(peer net.Addr, conn net.PacketConn, req, resp *dhcpv4.DHCPv4) {
<mask> switch giaddr, ciaddr, mtype := req.GatewayIPAddr, req.ClientIPAddr, resp.MessageType(); {
</s> Pull request: 4337 increase msg size
Merge in DNS/adguard-home from 4337-dhcp-msg-len to master
Updates #4337.
Squashed commit of the following:
commit 55e53c1fadd4ccb2a8b94117afff82e9a5d2734b
Merge: f37070ea da1ae338
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 14:14:21 2022 +0300
Merge branch 'master' into 4337-dhcp-msg-len
commit f37070ea0f3a7ff8efcbbafd36001f78d9b082b5
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 13:15:25 2022 +0300
dhcpd: imp ether pkt building
commit fa43a0bcc24d4ca5e9193899dbba8495f3de5df9
Author: Eugene Burkov <[email protected]>
Date: Tue Sep 6 18:55:07 2022 +0300
dhcpd: incr msg size </s> remove return 0, fmt.Errorf("peer is of unexpected type %T", addr)
</s> add return 0, fmt.Errorf("addr has an unexpected type %T", addr) </s> remove log.Debug("dhcpv4: sending to %s: %s", peer, resp.Summary())
if _, err := conn.WriteTo(resp.ToBytes(), peer); err != nil {
</s> add pktData := resp.ToBytes()
pktLen := len(pktData)
if pktLen < minDHCPMsgSize {
// Expand the packet to match the minimum DHCP message length. Although
// the dhpcv4 package deals with the BOOTP's lower packet length
// constraint, it seems some clients expecting the length being at least
// 576 bytes as per RFC 2131 (and an obsolete RFC 1533).
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/4337.
pktData = append(pktData, make([]byte, minDHCPMsgSize-pktLen)...)
}
log.Debug("dhcpv4: sending %d bytes to %s: %s", len(pktData), peer, resp.Summary())
_, err := conn.WriteTo(pktData, peer)
if err != nil { </s> remove func (c *dhcpConn) wrapErrs(action string, udpConnErr, rawConnErr error) (err error) {
</s> add func (*dhcpConn) wrapErrs(action string, udpConnErr, rawConnErr error) (err error) { </s> remove dhcpLayer := gopacket.NewPacket(payload, layers.LayerTypeDHCPv4, gopacket.DecodeOptions{
NoCopy: true,
}).Layer(layers.LayerTypeDHCPv4)
// Check if the decoding succeeded and the resulting layer doesn't
// contain any errors. It should guarantee panic-safe converting of the
// layer into gopacket.SerializableLayer.
if dhcpLayer == nil || dhcpLayer.LayerType() != layers.LayerTypeDHCPv4 {
return nil, errInvalidPktDHCP
}
</s> add </s> remove // ipv4DefaultTTL is the default Time to Live value as recommended by
// RFC-1700 (https://datatracker.ietf.org/doc/html/rfc1700) in seconds.
</s> add // ipv4DefaultTTL is the default Time to Live value in seconds as recommended by
// RFC-1700.
//
// See https://datatracker.ietf.org/doc/html/rfc1700. | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53209bc42c2401e017e5b727fb74272953a8cd0e | internal/dhcpd/v4.go |
pktData := resp.ToBytes()
pktLen := len(pktData)
if pktLen < minDHCPMsgSize {
// Expand the packet to match the minimum DHCP message length. Although
// the dhpcv4 package deals with the BOOTP's lower packet length
// constraint, it seems some clients expecting the length being at least
// 576 bytes as per RFC 2131 (and an obsolete RFC 1533).
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/4337.
pktData = append(pktData, make([]byte, minDHCPMsgSize-pktLen)...)
}
log.Debug("dhcpv4: sending %d bytes to %s: %s", len(pktData), peer, resp.Summary())
_, err := conn.WriteTo(pktData, peer)
if err != nil { | <mask> default:
<mask> // Go on since peer is already set to broadcast.
<mask> }
<mask>
<mask> log.Debug("dhcpv4: sending to %s: %s", peer, resp.Summary())
<mask> if _, err := conn.WriteTo(resp.ToBytes(), peer); err != nil {
<mask> log.Error("dhcpv4: conn.Write to %s failed: %s", peer, err)
<mask> }
<mask> }
<mask>
<mask> // Start starts the IPv4 DHCP server.
</s> Pull request: 4337 increase msg size
Merge in DNS/adguard-home from 4337-dhcp-msg-len to master
Updates #4337.
Squashed commit of the following:
commit 55e53c1fadd4ccb2a8b94117afff82e9a5d2734b
Merge: f37070ea da1ae338
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 14:14:21 2022 +0300
Merge branch 'master' into 4337-dhcp-msg-len
commit f37070ea0f3a7ff8efcbbafd36001f78d9b082b5
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 7 13:15:25 2022 +0300
dhcpd: imp ether pkt building
commit fa43a0bcc24d4ca5e9193899dbba8495f3de5df9
Author: Eugene Burkov <[email protected]>
Date: Tue Sep 6 18:55:07 2022 +0300
dhcpd: incr msg size </s> remove dhcpLayer := gopacket.NewPacket(payload, layers.LayerTypeDHCPv4, gopacket.DecodeOptions{
NoCopy: true,
}).Layer(layers.LayerTypeDHCPv4)
// Check if the decoding succeeded and the resulting layer doesn't
// contain any errors. It should guarantee panic-safe converting of the
// layer into gopacket.SerializableLayer.
if dhcpLayer == nil || dhcpLayer.LayerType() != layers.LayerTypeDHCPv4 {
return nil, errInvalidPktDHCP
}
</s> add </s> remove return 0, fmt.Errorf("peer is of unexpected type %T", addr)
</s> add return 0, fmt.Errorf("addr has an unexpected type %T", addr) </s> remove }, ethLayer, ipv4Layer, udpLayer, dhcpLayer.(gopacket.SerializableLayer))
</s> add }
err = gopacket.SerializeLayers(
buf,
setts,
ethLayer,
ipv4Layer,
udpLayer,
gopacket.Payload(payload),
) </s> remove err = gopacket.SerializeLayers(buf, gopacket.SerializeOptions{
</s> add setts := gopacket.SerializeOptions{ | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53209bc42c2401e017e5b727fb74272953a8cd0e | internal/dhcpd/v4.go |
log.Error("initializing tls: %s", err)
onConfigModified() | <mask> config.Users = nil
<mask>
<mask> Context.tls, err = newTLSManager(config.TLS)
<mask> if err != nil {
<mask> log.Fatalf("initializing tls: %s", err)
<mask> }
<mask>
<mask> Context.web, err = initWeb(opts, clientBuildFS)
<mask> fatalOnError(err)
<mask>
</s> Pull request: 5189-run-bad-cert
Merge in DNS/adguard-home from 5189-run-bad-cert to master
Closes #5189.
Squashed commit of the following:
commit 9e6ac6218163c7408200ce5fd591e8e6f5181f00
Author: Eugene Burkov <[email protected]>
Date: Thu Nov 24 19:17:43 2022 +0300
all: imp chlog again
commit 5870aee8efc3213feffbe1e61b2f5b411a69ece7
Author: Eugene Burkov <[email protected]>
Date: Thu Nov 24 18:57:54 2022 +0300
all: imp chlog
commit ec0d4b6ead14a6a6698d4a27819e679b2d4c7a0b
Author: Eugene Burkov <[email protected]>
Date: Thu Nov 24 18:43:04 2022 +0300
home: rm fatal on tls init errors </s> remove return nil, err
</s> add m.conf.Enabled = false
return m, err </s> remove // newTLSManager initializes the TLS configuration.
</s> add // newTLSManager initializes the manager of TLS configuration. m is always
// non-nil while any returned error indicates that the TLS configuration isn't
// valid. Thus TLS may be initialized later, e.g. via the web UI. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53a366ed463cf8cea1dec0e9619376cdb778ac52 | internal/home/home.go |
// newTLSManager initializes the manager of TLS configuration. m is always
// non-nil while any returned error indicates that the TLS configuration isn't
// valid. Thus TLS may be initialized later, e.g. via the web UI. | <mask> confLock sync.Mutex
<mask> conf tlsConfigSettings
<mask> }
<mask>
<mask> // newTLSManager initializes the TLS configuration.
<mask> func newTLSManager(conf tlsConfigSettings) (m *tlsManager, err error) {
<mask> m = &tlsManager{
<mask> status: &tlsConfigStatus{},
<mask> conf: conf,
<mask> }
</s> Pull request: 5189-run-bad-cert
Merge in DNS/adguard-home from 5189-run-bad-cert to master
Closes #5189.
Squashed commit of the following:
commit 9e6ac6218163c7408200ce5fd591e8e6f5181f00
Author: Eugene Burkov <[email protected]>
Date: Thu Nov 24 19:17:43 2022 +0300
all: imp chlog again
commit 5870aee8efc3213feffbe1e61b2f5b411a69ece7
Author: Eugene Burkov <[email protected]>
Date: Thu Nov 24 18:57:54 2022 +0300
all: imp chlog
commit ec0d4b6ead14a6a6698d4a27819e679b2d4c7a0b
Author: Eugene Burkov <[email protected]>
Date: Thu Nov 24 18:43:04 2022 +0300
home: rm fatal on tls init errors </s> remove return nil, err
</s> add m.conf.Enabled = false
return m, err </s> remove log.Fatalf("initializing tls: %s", err)
</s> add log.Error("initializing tls: %s", err)
onConfigModified() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53a366ed463cf8cea1dec0e9619376cdb778ac52 | internal/home/tls.go |
m.conf.Enabled = false
return m, err | <mask>
<mask> if m.conf.Enabled {
<mask> err = m.load()
<mask> if err != nil {
<mask> return nil, err
<mask> }
<mask>
<mask> m.setCertFileTime()
<mask> }
<mask>
</s> Pull request: 5189-run-bad-cert
Merge in DNS/adguard-home from 5189-run-bad-cert to master
Closes #5189.
Squashed commit of the following:
commit 9e6ac6218163c7408200ce5fd591e8e6f5181f00
Author: Eugene Burkov <[email protected]>
Date: Thu Nov 24 19:17:43 2022 +0300
all: imp chlog again
commit 5870aee8efc3213feffbe1e61b2f5b411a69ece7
Author: Eugene Burkov <[email protected]>
Date: Thu Nov 24 18:57:54 2022 +0300
all: imp chlog
commit ec0d4b6ead14a6a6698d4a27819e679b2d4c7a0b
Author: Eugene Burkov <[email protected]>
Date: Thu Nov 24 18:43:04 2022 +0300
home: rm fatal on tls init errors </s> remove log.Fatalf("initializing tls: %s", err)
</s> add log.Error("initializing tls: %s", err)
onConfigModified() </s> remove // newTLSManager initializes the TLS configuration.
</s> add // newTLSManager initializes the manager of TLS configuration. m is always
// non-nil while any returned error indicates that the TLS configuration isn't
// valid. Thus TLS may be initialized later, e.g. via the web UI. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53a366ed463cf8cea1dec0e9619376cdb778ac52 | internal/home/tls.go |
<mask> "strings"
<mask> "sync"
<mask> "time"
<mask>
<mask> "github.com/bluele/gcache"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/miekg/dns"
<mask> )
<mask>
<mask> type hourTop struct {
</s> Fix #597 - [bugfix] querylog_top: Empty domain gets to the Top Queried domains | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53d680a5dfb027831bdbfc91bde5272d4d849a1a | dnsforward/querylog_top.go |
|
"github.com/bluele/gcache" | <mask> "time"
<mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/miekg/dns"
<mask> )
<mask>
<mask> type hourTop struct {
<mask> domains gcache.Cache
<mask> blocked gcache.Cache
</s> Fix #597 - [bugfix] querylog_top: Empty domain gets to the Top Queried domains </s> remove "github.com/bluele/gcache"
</s> add | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53d680a5dfb027831bdbfc91bde5272d4d849a1a | dnsforward/querylog_top.go |
// if question hostname is empty, do nothing
if hostname == "" {
return nil
}
| <mask> }
<mask>
<mask> hostname := strings.ToLower(strings.TrimSuffix(q.Question[0].Name, "."))
<mask>
<mask> // get value, if not set, crate one
<mask> d.hoursReadLock()
<mask> defer d.hoursReadUnlock()
<mask> err := d.hours[hour].incrementDomains(hostname)
</s> Fix #597 - [bugfix] querylog_top: Empty domain gets to the Top Queried domains </s> remove "github.com/bluele/gcache"
</s> add | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/53d680a5dfb027831bdbfc91bde5272d4d849a1a | dnsforward/querylog_top.go |
<mask> }
<mask>
<mask> func (s *Server) handleDHCP4Request(p dhcp4.Packet, options dhcp4.Options) dhcp4.Packet {
<mask> var lease *Lease
<mask> var err error
<mask>
<mask> reqIP := net.IP(options[dhcp4.OptionRequestedIPAddress])
<mask> log.Tracef("Message from client: Request. IP: %s ReqIP: %s HW: %s",
<mask> p.CIAddr(), reqIP, p.CHAddr())
<mask>
</s> * dhcp: don't allocate a new lease when processing Request message </s> remove lease, err = s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
</s> add log.Tracef("Lease for %s isn't found", p.CHAddr())
return dhcp4.ReplyPacket(p, dhcp4.NAK, s.ipnet.IP, nil, 0, nil) </s> remove check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.ACK)}), "dhcp4.ACK")
check(t, bytes.Equal(p2.YIAddr(), []byte{1, 1, 1, 1}), "p2.YIAddr")
check(t, bytes.Equal(p2.CHAddr(), hw), "p2.CHAddr")
check(t, bytes.Equal(opt[dhcp4.OptionIPAddressLeaseTime], dhcp4.OptionsLeaseTime(5*time.Second)), "OptionIPAddressLeaseTime")
check(t, bytes.Equal(opt[dhcp4.OptionServerIdentifier], s.ipnet.IP), "OptionServerIdentifier")
</s> add check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.NAK)}), "dhcp4.NAK") </s> remove // Commit a lease for an IP without prior Discover-Offer packets
</s> add // Try to commit a lease for an IP without prior Discover-Offer packets </s> remove
// Try to reserve another IP for the same machine - no new IP must be reserved
hw = []byte{1, 2, 3, 4, 5, 6}
p.SetCHAddr(hw)
lease, _ = s.reserveLease(p)
</s> add lease = s.findLease(p) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/542a67b84edc067d864164fbb9f566447a97ccb8 | dhcpd/dhcpd.go |
|
log.Tracef("Lease for %s isn't found", p.CHAddr())
return dhcp4.ReplyPacket(p, dhcp4.NAK, s.ipnet.IP, nil, 0, nil) | <mask> }
<mask>
<mask> lease = s.findLease(p)
<mask> if lease == nil {
<mask> lease, err = s.reserveLease(p)
<mask> if err != nil {
<mask> log.Tracef("Couldn't find free lease: %s", err)
<mask> // couldn't find lease, don't respond
<mask> return nil
<mask> }
<mask> }
<mask>
<mask> if !lease.IP.Equal(reqIP) {
<mask> log.Tracef("Lease for %s doesn't match requested/client IP: %s vs %s",
<mask> lease.HWAddr, lease.IP, reqIP)
</s> * dhcp: don't allocate a new lease when processing Request message </s> remove var err error
</s> add </s> remove
// Try to reserve another IP for the same machine - no new IP must be reserved
hw = []byte{1, 2, 3, 4, 5, 6}
p.SetCHAddr(hw)
lease, _ = s.reserveLease(p)
</s> add lease = s.findLease(p) </s> remove check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.ACK)}), "dhcp4.ACK")
check(t, bytes.Equal(p2.YIAddr(), []byte{1, 1, 1, 1}), "p2.YIAddr")
check(t, bytes.Equal(p2.CHAddr(), hw), "p2.CHAddr")
check(t, bytes.Equal(opt[dhcp4.OptionIPAddressLeaseTime], dhcp4.OptionsLeaseTime(5*time.Second)), "OptionIPAddressLeaseTime")
check(t, bytes.Equal(opt[dhcp4.OptionServerIdentifier], s.ipnet.IP), "OptionServerIdentifier")
</s> add check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.NAK)}), "dhcp4.NAK") </s> remove // Commit a lease for an IP without prior Discover-Offer packets
</s> add // Try to commit a lease for an IP without prior Discover-Offer packets | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/542a67b84edc067d864164fbb9f566447a97ccb8 | dhcpd/dhcpd.go |
lease = s.findLease(p) | <mask> p.SetCHAddr(hw)
<mask> lease, _ = s.reserveLease(p)
<mask> check(t, bytes.Equal(lease.HWAddr, hw), "lease.HWAddr")
<mask> check(t, bytes.Equal(lease.IP, []byte{1, 1, 1, 1}), "lease.IP")
<mask>
<mask> // Try to reserve another IP for the same machine - no new IP must be reserved
<mask> hw = []byte{1, 2, 3, 4, 5, 6}
<mask> p.SetCHAddr(hw)
<mask> lease, _ = s.reserveLease(p)
<mask> check(t, bytes.Equal(lease.HWAddr, hw), "lease.HWAddr")
<mask> check(t, bytes.Equal(lease.IP, []byte{1, 1, 1, 1}), "lease.IP")
<mask>
<mask> // Reserve an IP - the next IP from the range
<mask> hw = []byte{2, 2, 3, 4, 5, 6}
</s> * dhcp: don't allocate a new lease when processing Request message </s> remove // Commit a lease for an IP without prior Discover-Offer packets
</s> add // Try to commit a lease for an IP without prior Discover-Offer packets </s> remove check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.ACK)}), "dhcp4.ACK")
check(t, bytes.Equal(p2.YIAddr(), []byte{1, 1, 1, 1}), "p2.YIAddr")
check(t, bytes.Equal(p2.CHAddr(), hw), "p2.CHAddr")
check(t, bytes.Equal(opt[dhcp4.OptionIPAddressLeaseTime], dhcp4.OptionsLeaseTime(5*time.Second)), "OptionIPAddressLeaseTime")
check(t, bytes.Equal(opt[dhcp4.OptionServerIdentifier], s.ipnet.IP), "OptionServerIdentifier")
</s> add check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.NAK)}), "dhcp4.NAK") </s> remove lease, err = s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
</s> add log.Tracef("Lease for %s isn't found", p.CHAddr())
return dhcp4.ReplyPacket(p, dhcp4.NAK, s.ipnet.IP, nil, 0, nil) </s> remove var err error
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/542a67b84edc067d864164fbb9f566447a97ccb8 | dhcpd/dhcpd_test.go |
// Try to commit a lease for an IP without prior Discover-Offer packets | <mask> var opt dhcp4.Options
<mask>
<mask> p = make(dhcp4.Packet, 241)
<mask>
<mask> // Commit a lease for an IP without prior Discover-Offer packets
<mask> hw = []byte{2, 2, 3, 4, 5, 6}
<mask> p.SetCHAddr(hw)
<mask> p.SetCIAddr([]byte{0, 0, 0, 0})
<mask> opt = make(dhcp4.Options, 10)
<mask> opt[dhcp4.OptionRequestedIPAddress] = []byte{1, 1, 1, 1}
</s> * dhcp: don't allocate a new lease when processing Request message </s> remove
// Try to reserve another IP for the same machine - no new IP must be reserved
hw = []byte{1, 2, 3, 4, 5, 6}
p.SetCHAddr(hw)
lease, _ = s.reserveLease(p)
</s> add lease = s.findLease(p) </s> remove check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.ACK)}), "dhcp4.ACK")
check(t, bytes.Equal(p2.YIAddr(), []byte{1, 1, 1, 1}), "p2.YIAddr")
check(t, bytes.Equal(p2.CHAddr(), hw), "p2.CHAddr")
check(t, bytes.Equal(opt[dhcp4.OptionIPAddressLeaseTime], dhcp4.OptionsLeaseTime(5*time.Second)), "OptionIPAddressLeaseTime")
check(t, bytes.Equal(opt[dhcp4.OptionServerIdentifier], s.ipnet.IP), "OptionServerIdentifier")
</s> add check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.NAK)}), "dhcp4.NAK") </s> remove lease, err = s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
</s> add log.Tracef("Lease for %s isn't found", p.CHAddr())
return dhcp4.ReplyPacket(p, dhcp4.NAK, s.ipnet.IP, nil, 0, nil) </s> remove var err error
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/542a67b84edc067d864164fbb9f566447a97ccb8 | dhcpd/dhcpd_test.go |
check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.NAK)}), "dhcp4.NAK") | <mask> opt = make(dhcp4.Options, 10)
<mask> opt[dhcp4.OptionRequestedIPAddress] = []byte{1, 1, 1, 1}
<mask> p2 = s.handleDHCP4Request(p, opt)
<mask> opt = p2.ParseOptions()
<mask> check(t, bytes.Equal(opt[dhcp4.OptionDHCPMessageType], []byte{byte(dhcp4.ACK)}), "dhcp4.ACK")
<mask> check(t, bytes.Equal(p2.YIAddr(), []byte{1, 1, 1, 1}), "p2.YIAddr")
<mask> check(t, bytes.Equal(p2.CHAddr(), hw), "p2.CHAddr")
<mask> check(t, bytes.Equal(opt[dhcp4.OptionIPAddressLeaseTime], dhcp4.OptionsLeaseTime(5*time.Second)), "OptionIPAddressLeaseTime")
<mask> check(t, bytes.Equal(opt[dhcp4.OptionServerIdentifier], s.ipnet.IP), "OptionServerIdentifier")
<mask> }
<mask>
<mask> // Leases database store/load
<mask> func TestDB(t *testing.T) {
<mask> var s = Server{}
</s> * dhcp: don't allocate a new lease when processing Request message </s> remove
// Try to reserve another IP for the same machine - no new IP must be reserved
hw = []byte{1, 2, 3, 4, 5, 6}
p.SetCHAddr(hw)
lease, _ = s.reserveLease(p)
</s> add lease = s.findLease(p) </s> remove // Commit a lease for an IP without prior Discover-Offer packets
</s> add // Try to commit a lease for an IP without prior Discover-Offer packets </s> remove lease, err = s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
</s> add log.Tracef("Lease for %s isn't found", p.CHAddr())
return dhcp4.ReplyPacket(p, dhcp4.NAK, s.ipnet.IP, nil, 0, nil) </s> remove var err error
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/542a67b84edc067d864164fbb9f566447a97ccb8 | dhcpd/dhcpd_test.go |
"dev": true,
"optional": true | <mask> },
<mask> "ansi-regex": {
<mask> "version": "2.1.1",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "aproba": {
<mask> "version": "1.2.0",
<mask> "bundled": true,
<mask> "dev": true,
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "balanced-match": {
<mask> "version": "1.0.0",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "brace-expansion": {
<mask> "version": "1.1.11",
<mask> "bundled": true,
<mask> "dev": true,
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"optional": true, | <mask> "brace-expansion": {
<mask> "version": "1.1.11",
<mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "balanced-match": "^1.0.0",
<mask> "concat-map": "0.0.1"
<mask> }
<mask> },
<mask> "chownr": {
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "code-point-at": {
<mask> "version": "1.1.0",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "concat-map": {
<mask> "version": "0.0.1",
<mask> "bundled": true,
<mask> "dev": true
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "concat-map": {
<mask> "version": "0.0.1",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "console-control-strings": {
<mask> "version": "1.1.0",
<mask> "bundled": true,
<mask> "dev": true
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "console-control-strings": {
<mask> "version": "1.1.0",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "core-util-is": {
<mask> "version": "1.0.2",
<mask> "bundled": true,
<mask> "dev": true,
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "inherits": {
<mask> "version": "2.0.3",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "ini": {
<mask> "version": "1.3.5",
<mask> "bundled": true,
<mask> "dev": true,
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"optional": true, | <mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "number-is-nan": "^1.0.0"
<mask> }
<mask> },
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"optional": true, | <mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "brace-expansion": "^1.1.7"
<mask> }
<mask> },
<mask> "minimist": {
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "minimist": {
<mask> "version": "0.0.8",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "minipass": {
<mask> "version": "2.2.4",
<mask> "bundled": true,
<mask> "dev": true,
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"optional": true, | <mask> "version": "2.2.4",
<mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "safe-buffer": "^5.1.1",
<mask> "yallist": "^3.0.0"
<mask> }
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"optional": true, | <mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "minimist": "0.0.8"
<mask> }
<mask> },
<mask> "ms": {
<mask> "version": "2.0.0",
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "number-is-nan": {
<mask> "version": "1.0.1",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "object-assign": {
<mask> "version": "4.1.1",
<mask> "bundled": true,
<mask> "dev": true,
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"optional": true, | <mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "wrappy": "1"
<mask> }
<mask> },
<mask> "os-homedir": {
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "safe-buffer": {
<mask> "version": "5.1.1",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "safer-buffer": {
<mask> "version": "2.1.2",
<mask> "bundled": true,
<mask> "dev": true,
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"optional": true, | <mask> "string-width": {
<mask> "version": "1.0.2",
<mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "code-point-at": "^1.0.0",
<mask> "is-fullwidth-code-point": "^1.0.0",
<mask> "strip-ansi": "^3.0.0"
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"optional": true, | <mask> "strip-ansi": {
<mask> "version": "3.0.1",
<mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "ansi-regex": "^2.0.0"
<mask> }
<mask> },
<mask> "strip-json-comments": {
<mask> "version": "2.0.1",
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "wrappy": {
<mask> "version": "1.0.2",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "yallist": {
<mask> "version": "3.0.2",
<mask> "bundled": true,
<mask> "dev": true
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
"dev": true,
"optional": true | <mask> },
<mask> "yallist": {
<mask> "version": "3.0.2",
<mask> "bundled": true,
<mask> "dev": true
<mask> }
<mask> }
<mask> },
<mask> "function-bind": {
<mask> "version": "1.1.1",
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed | client/package-lock.json |
<mask> ReqECS: pctx.ReqECS,
<mask> Answer: pctx.Res,
<mask> OrigAnswer: dctx.origResp,
<mask> Result: dctx.result,
<mask> Elapsed: elapsed,
<mask> ClientID: dctx.clientID,
<mask> ClientIP: ip,
<mask> AuthenticatedData: dctx.responseAD,
<mask> }
<mask>
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove ClientIP: client,
</s> add </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/dnsforward/stats.go |
|
Elapsed: elapsed, | <mask> Result: dctx.result,
<mask> ClientID: dctx.clientID,
<mask> ClientIP: ip,
<mask> AuthenticatedData: dctx.responseAD,
<mask> }
<mask>
<mask> switch pctx.Proto {
<mask> case proxy.ProtoHTTPS:
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove Elapsed: elapsed,
</s> add </s> remove ClientIP: client,
</s> add </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/dnsforward/stats.go |
Anonymizer: anonymizer, | <mask> return fmt.Errorf("init stats: %w", err)
<mask> }
<mask>
<mask> conf := querylog.Config{
<mask> ConfigModified: onConfigModified,
<mask> HTTPRegister: httpRegister,
<mask> FindClient: Context.clients.findMultiple,
<mask> BaseDir: baseDir,
<mask> RotationIvl: config.DNS.QueryLogInterval.Duration,
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> remove Anonymizer: anonymizer,
</s> add | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/home/dns.go |
<mask> MemSize: config.DNS.QueryLogMemSize,
<mask> Enabled: config.DNS.QueryLogEnabled,
<mask> FileEnabled: config.DNS.QueryLogFileEnabled,
<mask> AnonymizeClientIP: config.DNS.AnonymizeClientIP,
<mask> Anonymizer: anonymizer,
<mask> }
<mask> Context.queryLog = querylog.New(conf)
<mask>
<mask> filterConf := config.DNS.DnsfilterConf
<mask> filterConf.EtcHosts = Context.etcHosts
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/home/dns.go |
|
<mask> "golang.org/x/net/idna"
<mask> )
<mask>
<mask> type qlogConfig struct {
<mask> Enabled bool `json:"enabled"`
<mask> // Use float64 here to support fractional numbers and not mess the API
<mask> // users by changing the units.
<mask> Interval float64 `json:"interval"`
<mask> AnonymizeClientIP bool `json:"anonymize_client_ip"`
<mask> }
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/http.go |
|
Enabled bool `json:"enabled"` | <mask> // Use float64 here to support fractional numbers and not mess the API
<mask> // users by changing the units.
<mask> Interval float64 `json:"interval"`
<mask> AnonymizeClientIP bool `json:"anonymize_client_ip"`
<mask> }
<mask>
<mask> // Register web handlers
<mask> func (l *queryLog) initWeb() {
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove Enabled bool `json:"enabled"`
</s> add </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/http.go |
log.Debug("querylog: cleared") | <mask> if err != nil && !errors.Is(err, os.ErrNotExist) {
<mask> log.Error("removing log file %q: %s", l.logFile, err)
<mask> }
<mask>
<mask> log.Debug("Query log: cleared")
<mask> }
<mask>
<mask> func (l *queryLog) Add(params *AddParams) {
<mask> if !l.conf.Enabled {
<mask> return
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/qlog.go |
<mask> Question: &q,
<mask> Answer: &a,
<mask> OrigAnswer: &a,
<mask> Result: &res,
<mask> ClientIP: client,
<mask> Upstream: "upstream",
<mask> }
<mask>
<mask> l.Add(params)
<mask> }
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove Elapsed: elapsed,
</s> add </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/qlog_test.go |
|
ClientIP: client, | <mask> Result: &res,
<mask> Upstream: "upstream",
<mask> }
<mask>
<mask> l.Add(params)
<mask> }
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove ClientIP: client,
</s> add </s> remove Elapsed: elapsed,
</s> add </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/qlog_test.go |
// Config is the query log configuration structure. | <mask> // WriteDiskConfig - write configuration
<mask> WriteDiskConfig(c *Config)
<mask> }
<mask>
<mask> // Config - configuration object
<mask> type Config struct {
<mask> // ConfigModified is called when the configuration is changed, for
<mask> // example by HTTP requests.
<mask> ConfigModified func()
<mask>
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> remove Enabled bool `json:"enabled"`
</s> add </s> remove // Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> add </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/querylog.go |
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
| <mask> }
<mask>
<mask> // Config is the query log configuration structure.
<mask> type Config struct {
<mask> // ConfigModified is called when the configuration is changed, for
<mask> // example by HTTP requests.
<mask> ConfigModified func()
<mask>
<mask> // HTTPRegister registers an HTTP handler.
<mask> HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request))
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> remove // Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> add </s> remove Enabled bool `json:"enabled"`
</s> add | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/querylog.go |
<mask>
<mask> // AnonymizeClientIP tells if the query log should anonymize clients' IP
<mask> // addresses.
<mask> AnonymizeClientIP bool
<mask>
<mask> // Anonymizer processes the IP addresses to anonymize those if needed.
<mask> Anonymizer *aghnet.IPMut
<mask> }
<mask>
<mask> // AddParams is the parameters for adding an entry.
<mask> type AddParams struct {
<mask> Question *dns.Msg
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove Enabled bool `json:"enabled"`
</s> add </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/querylog.go |
|
<mask>
<mask> // Result is the filtering result (optional).
<mask> Result *filtering.Result
<mask>
<mask> // Elapsed is the time spent for processing the request.
<mask> Elapsed time.Duration
<mask>
<mask> ClientID string
<mask>
<mask> ClientIP net.IP
<mask>
<mask> // Upstream is the URL of the upstream DNS server.
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove ClientIP net.IP
</s> add </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/querylog.go |
|
<mask> Elapsed time.Duration
<mask>
<mask> ClientID string
<mask>
<mask> ClientIP net.IP
<mask>
<mask> // Upstream is the URL of the upstream DNS server.
<mask> Upstream string
<mask>
<mask> ClientProto ClientProto
<mask>
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove // Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> add </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/querylog.go |
|
ClientIP net.IP
// Elapsed is the time spent for processing the request.
Elapsed time.Duration
| <mask> Upstream string
<mask>
<mask> ClientProto ClientProto
<mask>
<mask> // Cached indicates if the response is served from cache.
<mask> Cached bool
<mask>
<mask> // AuthenticatedData shows if the response had the AD bit set.
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove ClientIP net.IP
</s> add </s> remove // Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> add </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/querylog.go |
func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { | <mask> }
<mask>
<mask> // search - searches log entries in the query log using specified parameters
<mask> // returns the list of entries found + time of the oldest entry
<mask> func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
<mask> now := time.Now()
<mask>
<mask> if params.limit == 0 {
<mask> return []*logEntry{}, time.Time{}
<mask> }
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/search.go |
entries = append(memoryEntries, fileEntries...) | <mask>
<mask> totalLimit := params.offset + params.limit
<mask>
<mask> // now let's get a unified collection
<mask> entries := append(memoryEntries, fileEntries...)
<mask> if len(entries) > totalLimit {
<mask> // remove extra records
<mask> entries = entries[:totalLimit]
<mask> }
<mask>
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove Anonymizer: anonymizer,
</s> add </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/search.go |
if len(entries) > 0 { | <mask> oldest = time.Time{}
<mask> }
<mask> }
<mask>
<mask> if len(entries) > 0 && len(entries) <= totalLimit {
<mask> // Update oldest after merging in the memory buffer.
<mask> oldest = entries[len(entries)-1].Time
<mask> }
<mask>
<mask> log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/search.go |
log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) | <mask> // Update oldest after merging in the memory buffer.
<mask> oldest = entries[len(entries)-1].Time
<mask> }
<mask>
<mask> log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
<mask> len(entries), total, params.olderThan, time.Since(now))
<mask>
<mask> return entries, oldest
<mask> }
<mask>
<mask> // searchFiles looks up log records from all log files. It optionally uses the
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/search.go |
oldestNano = 0
| <mask>
<mask> e, ts, err = l.readNextEntry(r, params, cache)
<mask> if err != nil {
<mask> if err == io.EOF {
<mask> break
<mask> }
<mask>
<mask> log.Error("querylog: reading next entry: %s", err)
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80 | internal/querylog/search.go |
<mask> *.snap
<mask> /agh-backup/
<mask> /bin/
<mask> /build/*
<mask> /build2/*
<mask> /data/
<mask> /dist/
<mask> /filtering/tests/filtering.TestLotsOfRules*.pprof
<mask> /filtering/tests/top-1m.csv
<mask> /launchpad_credentials
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove clientFS: clientFS,
clientBetaFS: clientBetaFS,
</s> add clientFS: clientFS, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | .gitignore |
|
<mask> leases.db
<mask> node_modules/
<mask>
<mask> !/build/gitkeep
<mask> !/build2/gitkeep
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove if [ "$( git diff --cached --name-only -- 'client2/*.js' 'client2/*.ts' 'client2/*.tsx' )" ]
then
make VERBOSE="$verbose" js-beta-lint js-beta-test
fi
</s> add </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: | [
"keep",
"keep",
"keep",
"keep",
"replace"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | .gitignore |
|
<mask> # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
<mask> .POSIX:
<mask>
<mask> CHANNEL = development
<mask> CLIENT_BETA_DIR = client2
<mask> CLIENT_DIR = client
<mask> COMMIT = $$( git rev-parse --short HEAD )
<mask> DIST_DIR = dist
<mask> # Don't name this macro "GO", because GNU Make apparenly makes it an
<mask> # exported environment variable with the literal value of "${GO:-go}",
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
YARN_INSTALL_FLAGS = $(YARN_FLAGS) --network-timeout 120000 --silent\
--ignore-engines --ignore-optional --ignore-platform\
--ignore-scripts
</s> add </s> remove $(YARN) $(YARN_FLAGS) build
</s> add </s> remove js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
</s> add </s> remove $(YARN) $(YARN_INSTALL_FLAGS) install
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | Makefile |
|
<mask> SIGN = 1
<mask> VERBOSE = 0
<mask> VERSION = v0.0.0
<mask> YARN = yarn
<mask> YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
<mask> YARN_INSTALL_FLAGS = $(YARN_FLAGS) --network-timeout 120000 --silent\
<mask> --ignore-engines --ignore-optional --ignore-platform\
<mask> --ignore-scripts
<mask>
<mask> NEXTAPI = 0
<mask>
<mask> # Macros for the build-release target. If FRONTEND_PREBUILT is 0, the
<mask> # default, the macro $(BUILD_RELEASE_DEPS_$(FRONTEND_PREBUILT)) expands
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove CLIENT_BETA_DIR = client2
</s> add </s> remove js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove $(YARN) $(YARN_INSTALL_FLAGS) install
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | Makefile |
|
<mask> init: ; git config core.hooksPath ./scripts/hooks
<mask>
<mask> js-build:
<mask> $(NPM) $(NPM_FLAGS) run build-prod
<mask> $(YARN) $(YARN_FLAGS) build
<mask> js-deps:
<mask> $(NPM) $(NPM_INSTALL_FLAGS) ci
<mask> $(YARN) $(YARN_INSTALL_FLAGS) install
<mask>
<mask> # TODO(a.garipov): Remove the legacy client tasks support once the new
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove $(YARN) $(YARN_INSTALL_FLAGS) install
</s> add </s> remove js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
</s> add </s> remove CLIENT_BETA_DIR = client2
</s> add </s> remove YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
YARN_INSTALL_FLAGS = $(YARN_FLAGS) --network-timeout 120000 --silent\
--ignore-engines --ignore-optional --ignore-platform\
--ignore-scripts
</s> add </s> remove //go:embed build build2
</s> add //go:embed build | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | Makefile |
|
<mask> $(NPM) $(NPM_FLAGS) run build-prod
<mask> $(YARN) $(YARN_FLAGS) build
<mask> js-deps:
<mask> $(NPM) $(NPM_INSTALL_FLAGS) ci
<mask> $(YARN) $(YARN_INSTALL_FLAGS) install
<mask>
<mask> # TODO(a.garipov): Remove the legacy client tasks support once the new
<mask> # client is done and the old one is removed.
<mask> js-lint: ; $(NPM) $(NPM_FLAGS) run lint
<mask> js-test: ; $(NPM) $(NPM_FLAGS) run test
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove $(YARN) $(YARN_FLAGS) build
</s> add </s> remove js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
</s> add </s> remove YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
YARN_INSTALL_FLAGS = $(YARN_FLAGS) --network-timeout 120000 --silent\
--ignore-engines --ignore-optional --ignore-platform\
--ignore-scripts
</s> add </s> remove CLIENT_BETA_DIR = client2
</s> add </s> remove //go:embed build build2
</s> add //go:embed build | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | Makefile |
|
<mask> # TODO(a.garipov): Remove the legacy client tasks support once the new
<mask> # client is done and the old one is removed.
<mask> js-lint: ; $(NPM) $(NPM_FLAGS) run lint
<mask> js-test: ; $(NPM) $(NPM_FLAGS) run test
<mask> js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
<mask> js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
<mask>
<mask> go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
<mask> go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
<mask> go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
<mask> go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove $(YARN) $(YARN_INSTALL_FLAGS) install
</s> add </s> remove $(YARN) $(YARN_FLAGS) build
</s> add </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add </s> remove YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
YARN_INSTALL_FLAGS = $(YARN_FLAGS) --network-timeout 120000 --silent\
--ignore-engines --ignore-optional --ignore-platform\
--ignore-scripts
</s> add </s> remove CLIENT_BETA_DIR = client2
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | Makefile |
|
<mask> // BindHost is the address for the web interface server to listen on.
<mask> BindHost netip.Addr `yaml:"bind_host"`
<mask> // BindPort is the port for the web interface server to listen on.
<mask> BindPort int `yaml:"bind_port"`
<mask> // BetaBindPort is the port for the new client's web interface server to
<mask> // listen on.
<mask> BetaBindPort int `yaml:"beta_bind_port"`
<mask>
<mask> // Users are the clients capable for accessing the web interface.
<mask> Users []webUser `yaml:"users"`
<mask> // AuthAttempts is the maximum number of failed login attempts a user
<mask> // can do before being blocked.
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int </s> remove clientFS fs.FS
clientBetaFS fs.FS
</s> add clientFS fs.FS </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/config.go |
|
<mask> //
<mask> // TODO(a.garipov, e.burkov): This global is awful and must be removed.
<mask> var config = &configuration{
<mask> BindPort: 3000,
<mask> BetaBindPort: 0,
<mask> BindHost: netip.IPv4Unspecified(),
<mask> AuthAttempts: 5,
<mask> AuthBlockMin: 15,
<mask> WebSessionTTLHours: 30 * 24,
<mask> DNS: dnsConfig{
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort,
BetaBindPort: config.BetaBindPort,
</s> add firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort, </s> remove // This must be removed in API v1.
w.registerBetaInstallHandlers()
</s> add </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/config.go |
|
addPorts(tcpPorts, tcpPort(config.BindPort)) | <mask> return err
<mask> }
<mask>
<mask> tcpPorts := aghalg.UniqChecker[tcpPort]{}
<mask> addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
<mask>
<mask> udpPorts := aghalg.UniqChecker[udpPort]{}
<mask> addPorts(udpPorts, udpPort(config.DNS.Port))
<mask>
<mask> if config.TLS.Enabled {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove addPorts(tcpPorts, tcpPort(opts.bindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(opts.bindPort)) </s> remove tcpPort(betaBindPort),
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove tcpPort(config.BetaBindPort),
</s> add </s> remove tcpPort(config.BetaBindPort),
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/config.go |
<mask> "os"
<mask> "os/exec"
<mask> "path/filepath"
<mask> "runtime"
<mask> "strings"
<mask> "time"
<mask> "unicode/utf8"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghalg"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove if [ "$( git diff --cached --name-only -- 'client2/*.js' 'client2/*.ts' 'client2/*.tsx' )" ]
then
make VERBOSE="$verbose" js-beta-lint js-beta-test
fi
</s> add </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/controlinstall.go |
|
addPorts(tcpPorts, port) | <mask> defer func() { err = errors.Annotate(err, "validating ports: %w") }()
<mask>
<mask> portInt := req.Web.Port
<mask> port := tcpPort(portInt)
<mask> addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
<mask> if err = tcpPorts.Validate(); err != nil {
<mask> // Reset the value for the port to 1 to make sure that validateDNS
<mask> // doesn't throw the same error, unless the same TCP port is set there
<mask> // as well.
<mask> tcpPorts[port] = 1
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/controlinstall.go |
<mask> // configuration structures.
<mask> func copyInstallSettings(dst, src *configuration) {
<mask> dst.BindHost = src.BindHost
<mask> dst.BindPort = src.BindPort
<mask> dst.BetaBindPort = src.BetaBindPort
<mask> dst.DNS.BindHosts = src.DNS.BindHosts
<mask> dst.DNS.Port = src.DNS.Port
<mask> }
<mask>
<mask> // shutdownTimeout is the timeout for shutting HTTP server down operation.
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove switch version.Channel() {
case version.ChannelEdge, version.ChannelDevelopment:
config.BetaBindPort = 3001
default:
// Go on.
}
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/controlinstall.go |
|
<mask> ctx, cancel := context.WithTimeout(context.Background(), timeout)
<mask> defer cancel()
<mask>
<mask> shutdownSrv(ctx, web.httpServer)
<mask> shutdownSrv(ctx, web.httpServerBeta)
<mask> }(shutdownTimeout)
<mask> }
<mask>
<mask> // decodeApplyConfigReq decodes the configuration, validates some parameters,
<mask> // and returns it along with the boolean indicating whether or not the HTTP
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove bindPort, betaBindPort, dohPort, dotPort, dnscryptTCPPort tcpPort,
</s> add bindPort, dohPort, dotPort, dnscryptTCPPort tcpPort, </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/controlinstall.go |
|
<mask> Context.mux.HandleFunc("/control/install/get_addresses", preInstall(ensureGET(web.handleInstallGetAddresses)))
<mask> Context.mux.HandleFunc("/control/install/check_config", preInstall(ensurePOST(web.handleInstallCheckConfig)))
<mask> Context.mux.HandleFunc("/control/install/configure", preInstall(ensurePOST(web.handleInstallConfigure)))
<mask> }
<mask>
<mask> // checkConfigReqEntBeta is a struct representing new client's config check
<mask> // request entry. It supports multiple IP values unlike the checkConfigReqEnt.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default checkConfigReqEnt.
<mask> type checkConfigReqEntBeta struct {
<mask> IP []netip.Addr `json:"ip"`
<mask> Port int `json:"port"`
<mask> Autofix bool `json:"autofix"`
<mask> }
<mask>
<mask> // checkConfigReqBeta is a struct representing new client's config check request
<mask> // body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default checkConfigReq.
<mask> type checkConfigReqBeta struct {
<mask> Web checkConfigReqEntBeta `json:"web"`
<mask> DNS checkConfigReqEntBeta `json:"dns"`
<mask> SetStaticIP bool `json:"set_static_ip"`
<mask> }
<mask>
<mask> // handleInstallCheckConfigBeta is a substitution of /install/check_config
<mask> // handler for new client.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default handleInstallCheckConfig.
<mask> func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
<mask> reqData := checkConfigReqBeta{}
<mask> err := json.NewDecoder(r.Body).Decode(&reqData)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
<mask>
<mask> return
<mask> }
<mask>
<mask> nonBetaReqData := checkConfReq{
<mask> Web: checkConfReqEnt{
<mask> IP: reqData.Web.IP[0],
<mask> Port: reqData.Web.Port,
<mask> Autofix: reqData.Web.Autofix,
<mask> },
<mask> DNS: checkConfReqEnt{
<mask> IP: reqData.DNS.IP[0],
<mask> Port: reqData.DNS.Port,
<mask> Autofix: reqData.DNS.Autofix,
<mask> },
<mask> SetStaticIP: reqData.SetStaticIP,
<mask> }
<mask>
<mask> nonBetaReqBody := &strings.Builder{}
<mask>
<mask> err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> body := nonBetaReqBody.String()
<mask> r.Body = io.NopCloser(strings.NewReader(body))
<mask> r.ContentLength = int64(len(body))
<mask>
<mask> web.handleInstallCheckConfig(w, r)
<mask> }
<mask>
<mask> // applyConfigReqEntBeta is a struct representing new client's config setting
<mask> // request entry. It supports multiple IP values unlike the applyConfigReqEnt.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default applyConfigReqEnt.
<mask> type applyConfigReqEntBeta struct {
<mask> IP []netip.Addr `json:"ip"`
<mask> Port int `json:"port"`
<mask> }
<mask>
<mask> // applyConfigReqBeta is a struct representing new client's config setting
<mask> // request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default applyConfigReq.
<mask> type applyConfigReqBeta struct {
<mask> Username string `json:"username"`
<mask> Password string `json:"password"`
<mask>
<mask> Web applyConfigReqEntBeta `json:"web"`
<mask> DNS applyConfigReqEntBeta `json:"dns"`
<mask> }
<mask>
<mask> // handleInstallConfigureBeta is a substitution of /install/configure handler
<mask> // for new client.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default handleInstallConfigure.
<mask> func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
<mask> reqData := applyConfigReqBeta{}
<mask> err := json.NewDecoder(r.Body).Decode(&reqData)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
<mask>
<mask> return
<mask> }
<mask>
<mask> nonBetaReqData := applyConfigReq{
<mask> Web: applyConfigReqEnt{
<mask> IP: reqData.Web.IP[0],
<mask> Port: reqData.Web.Port,
<mask> },
<mask> DNS: applyConfigReqEnt{
<mask> IP: reqData.DNS.IP[0],
<mask> Port: reqData.DNS.Port,
<mask> },
<mask> Username: reqData.Username,
<mask> Password: reqData.Password,
<mask> }
<mask>
<mask> nonBetaReqBody := &strings.Builder{}
<mask>
<mask> err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
<mask>
<mask> return
<mask> }
<mask> body := nonBetaReqBody.String()
<mask> r.Body = io.NopCloser(strings.NewReader(body))
<mask> r.ContentLength = int64(len(body))
<mask>
<mask> web.handleInstallConfigure(w, r)
<mask> }
<mask>
<mask> // getAddrsResponseBeta is a struct representing new client's getting addresses
<mask> // request body. It uses array of structs instead of map.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default firstRunData.
<mask> type getAddrsResponseBeta struct {
<mask> Interfaces []*aghnet.NetInterface `json:"interfaces"`
<mask> WebPort int `json:"web_port"`
<mask> DNSPort int `json:"dns_port"`
<mask> }
<mask>
<mask> // handleInstallConfigureBeta is a substitution of /install/get_addresses
<mask> // handler for new client.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default handleInstallGetAddresses.
<mask> func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
<mask> data := getAddrsResponseBeta{
<mask> WebPort: defaultPortHTTP,
<mask> DNSPort: defaultPortDNS,
<mask> }
<mask>
<mask> ifaces, err := aghnet.GetValidNetInterfacesForWeb()
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> data.Interfaces = ifaces
<mask>
<mask> _ = aghhttp.WriteJSONResponse(w, r, data)
<mask> }
<mask>
<mask> // registerBetaInstallHandlers registers the install handlers for new client
<mask> // with the structures it supports.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default handlers.
<mask> func (web *Web) registerBetaInstallHandlers() {
<mask> Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
<mask> Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
<mask> Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove // This must be removed in API v1.
w.registerBetaInstallHandlers()
</s> add </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int | [
"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",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/controlinstall.go |
|
<mask>
<mask> func setupContext(opts options) {
<mask> setupContextFlags(opts)
<mask>
<mask> switch version.Channel() {
<mask> case version.ChannelEdge, version.ChannelDevelopment:
<mask> config.BetaBindPort = 3001
<mask> default:
<mask> // Go on.
<mask> }
<mask>
<mask> Context.tlsRoots = aghtls.SystemRootCAs()
<mask> Context.transport = &http.Transport{
<mask> DialContext: customDialContext,
<mask> Proxy: getHTTPProxy,
<mask> TLSClientConfig: &tls.Config{
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove dst.BetaBindPort = src.BetaBindPort
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
|
addPorts(tcpPorts, tcpPort(opts.bindPort)) | <mask> Context.clients.Init(config.Clients.Persistent, Context.dhcpServer, Context.etcHosts, arpdb)
<mask>
<mask> if opts.bindPort != 0 {
<mask> tcpPorts := aghalg.UniqChecker[tcpPort]{}
<mask> addPorts(tcpPorts, tcpPort(opts.bindPort), tcpPort(config.BetaBindPort))
<mask>
<mask> udpPorts := aghalg.UniqChecker[udpPort]{}
<mask> addPorts(udpPorts, udpPort(config.DNS.Port))
<mask>
<mask> if config.TLS.Enabled {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove tcpPort(betaBindPort),
</s> add </s> remove bindPort, betaBindPort, dohPort, dotPort, dnscryptTCPPort tcpPort,
</s> add bindPort, dohPort, dotPort, dnscryptTCPPort tcpPort, </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
var clientFS fs.FS | <mask> return nil
<mask> }
<mask>
<mask> func initWeb(opts options, clientBuildFS fs.FS) (web *Web, err error) {
<mask> var clientFS, clientBetaFS fs.FS
<mask> if opts.localFrontend {
<mask> log.Info("warning: using local frontend files")
<mask>
<mask> clientFS = os.DirFS("build/static")
<mask> clientBetaFS = os.DirFS("build2/static")
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove clientFS fs.FS
clientBetaFS fs.FS
</s> add clientFS fs.FS </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
<mask> if opts.localFrontend {
<mask> log.Info("warning: using local frontend files")
<mask>
<mask> clientFS = os.DirFS("build/static")
<mask> clientBetaFS = os.DirFS("build2/static")
<mask> } else {
<mask> clientFS, err = fs.Sub(clientBuildFS, "build/static")
<mask> if err != nil {
<mask> return nil, fmt.Errorf("getting embedded client subdir: %w", err)
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove clientFS fs.FS
clientBetaFS fs.FS
</s> add clientFS fs.FS | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
|
<mask> clientFS, err = fs.Sub(clientBuildFS, "build/static")
<mask> if err != nil {
<mask> return nil, fmt.Errorf("getting embedded client subdir: %w", err)
<mask> }
<mask>
<mask> clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
<mask> if err != nil {
<mask> return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
<mask> }
<mask> }
<mask>
<mask> webConf := webConfig{
<mask> firstRun: Context.firstRun,
<mask> BindHost: config.BindHost,
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort,
BetaBindPort: config.BetaBindPort,
</s> add firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort, </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
|
firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort, | <mask> }
<mask> }
<mask>
<mask> webConf := webConfig{
<mask> firstRun: Context.firstRun,
<mask> BindHost: config.BindHost,
<mask> BindPort: config.BindPort,
<mask> BetaBindPort: config.BetaBindPort,
<mask>
<mask> ReadTimeout: readTimeout,
<mask> ReadHeaderTimeout: readHdrTimeout,
<mask> WriteTimeout: writeTimeout,
<mask>
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove clientFS: clientFS,
clientBetaFS: clientBetaFS,
</s> add clientFS: clientFS, </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove BetaBindPort: 0,
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove printWebAddrs(proto, addr.String(), config.BindPort, config.BetaBindPort)
</s> add printWebAddrs(proto, addr.String(), config.BindPort) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
clientFS: clientFS, | <mask> ReadTimeout: readTimeout,
<mask> ReadHeaderTimeout: readHdrTimeout,
<mask> WriteTimeout: writeTimeout,
<mask>
<mask> clientFS: clientFS,
<mask> clientBetaFS: clientBetaFS,
<mask>
<mask> serveHTTP3: config.DNS.ServeHTTP3,
<mask> }
<mask>
<mask> web = newWeb(&webConf)
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort,
BetaBindPort: config.BetaBindPort,
</s> add firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort, </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
// port. At least one address is printed with the value of port. Output
// example: | <mask> return opts
<mask> }
<mask>
<mask> // printWebAddrs prints addresses built from proto, addr, and an appropriate
<mask> // port. At least one address is printed with the value of port. If the value
<mask> // of betaPort is 0, the second address is not printed. Output example:
<mask> //
<mask> // Go to http://127.0.0.1:80
<mask> // Go to http://127.0.0.1:3000 (BETA)
<mask> func printWebAddrs(proto, addr string, port, betaPort int) {
<mask> const (
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int </s> remove //go:embed build2
</s> add //go:embed build | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
// go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) | <mask> // printWebAddrs prints addresses built from proto, addr, and an appropriate
<mask> // port. At least one address is printed with the value of port. If the value
<mask> // of betaPort is 0, the second address is not printed. Output example:
<mask> //
<mask> // Go to http://127.0.0.1:80
<mask> // Go to http://127.0.0.1:3000 (BETA)
<mask> func printWebAddrs(proto, addr string, port, betaPort int) {
<mask> const (
<mask> hostMsg = "Go to %s://%s"
<mask> hostBetaMsg = hostMsg + " (BETA)"
<mask> )
<mask>
<mask> log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
<mask> if betaPort == 0 {
<mask> return
<mask> }
<mask>
<mask> log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
<mask> }
<mask>
<mask> // printHTTPAddresses prints the IP addresses which user can use to access the
<mask> // admin interface. proto is either schemeHTTP or schemeHTTPS.
<mask> func printHTTPAddresses(proto string) {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove //go:embed build2
</s> add //go:embed build | [
"keep",
"keep",
"keep",
"keep",
"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/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) | <mask> }
<mask>
<mask> // TODO(e.burkov): Inspect and perhaps merge with the previous condition.
<mask> if proto == aghhttp.SchemeHTTPS && tlsConf.ServerName != "" {
<mask> printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
<mask>
<mask> return
<mask> }
<mask>
<mask> bindhost := config.BindHost
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
printWebAddrs(proto, bindhost.String(), port) | <mask> }
<mask>
<mask> bindhost := config.BindHost
<mask> if !bindhost.IsUnspecified() {
<mask> printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
<mask>
<mask> return
<mask> }
<mask>
<mask> ifaces, err := aghnet.GetValidNetInterfacesForWeb()
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove printWebAddrs(proto, addr.String(), config.BindPort, config.BetaBindPort)
</s> add printWebAddrs(proto, addr.String(), config.BindPort) </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
printWebAddrs(proto, bindhost.String(), port) | <mask> log.Error("web: getting iface ips: %s", err)
<mask> // That's weird, but we'll ignore it.
<mask> //
<mask> // TODO(e.burkov): Find out when it happens.
<mask> printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
<mask>
<mask> return
<mask> }
<mask>
<mask> for _, iface := range ifaces {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove printWebAddrs(proto, addr.String(), config.BindPort, config.BetaBindPort)
</s> add printWebAddrs(proto, addr.String(), config.BindPort) </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
printWebAddrs(proto, addr.String(), config.BindPort) | <mask> }
<mask>
<mask> for _, iface := range ifaces {
<mask> for _, addr := range iface.Addresses {
<mask> printWebAddrs(proto, addr.String(), config.BindPort, config.BetaBindPort)
<mask> }
<mask> }
<mask> }
<mask>
<mask> // -------------------
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort,
BetaBindPort: config.BetaBindPort,
</s> add firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort, </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/home.go |
<mask>
<mask> h.ServeHTTP(w, rr)
<mask> })
<mask> }
<mask>
<mask> // wrapIndexBeta returns handler that deals with new client.
<mask> func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
<mask> return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
<mask> h, pattern := Context.mux.Handler(r)
<mask> switch pattern {
<mask> case "/":
<mask> web.handlerBeta.ServeHTTP(w, r)
<mask> case "/install.html":
<mask> web.installerBeta.ServeHTTP(w, r)
<mask> default:
<mask> h.ServeHTTP(w, r)
<mask> }
<mask> })
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove switch version.Channel() {
case version.ChannelEdge, version.ChannelDevelopment:
config.BetaBindPort = 3001
default:
// Go on.
}
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/middlewares.go |
|
<mask>
<mask> if setts.Enabled {
<mask> err = validatePorts(
<mask> tcpPort(config.BindPort),
<mask> tcpPort(config.BetaBindPort),
<mask> tcpPort(setts.PortHTTPS),
<mask> tcpPort(setts.PortDNSOverTLS),
<mask> tcpPort(setts.PortDNSCrypt),
<mask> udpPort(config.DNS.Port),
<mask> udpPort(setts.PortDNSOverQUIC),
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove tcpPort(config.BetaBindPort),
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/tls.go |
|
<mask>
<mask> if req.Enabled {
<mask> err = validatePorts(
<mask> tcpPort(config.BindPort),
<mask> tcpPort(config.BetaBindPort),
<mask> tcpPort(req.PortHTTPS),
<mask> tcpPort(req.PortDNSOverTLS),
<mask> tcpPort(req.PortDNSCrypt),
<mask> udpPort(config.DNS.Port),
<mask> udpPort(req.PortDNSOverQUIC),
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove tcpPort(config.BetaBindPort),
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/tls.go |
|
bindPort, dohPort, dotPort, dnscryptTCPPort tcpPort, | <mask>
<mask> // validatePorts validates the uniqueness of TCP and UDP ports for AdGuard Home
<mask> // DNS protocols.
<mask> func validatePorts(
<mask> bindPort, betaBindPort, dohPort, dotPort, dnscryptTCPPort tcpPort,
<mask> dnsPort, doqPort udpPort,
<mask> ) (err error) {
<mask> tcpPorts := aghalg.UniqChecker[tcpPort]{}
<mask> addPorts(
<mask> tcpPorts,
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove tcpPort(betaBindPort),
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(opts.bindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(opts.bindPort)) </s> remove 'InitialConfigurationBeta':
'type': 'object'
'description': >
AdGuard Home initial configuration for the first-install wizard.
'required':
- 'dns'
- 'web'
- 'username'
- 'password'
'properties':
'dns':
'$ref': '#/components/schemas/AddressInfoBeta'
'web':
'$ref': '#/components/schemas/AddressInfoBeta'
'username':
'type': 'string'
'description': 'Basic auth username'
'example': 'admin'
'password':
'type': 'string'
'description': 'Basic auth password'
'example': 'password'
</s> add </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/tls.go |
<mask> tcpPorts := aghalg.UniqChecker[tcpPort]{}
<mask> addPorts(
<mask> tcpPorts,
<mask> tcpPort(bindPort),
<mask> tcpPort(betaBindPort),
<mask> tcpPort(dohPort),
<mask> tcpPort(dotPort),
<mask> tcpPort(dnscryptTCPPort),
<mask> )
<mask>
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove bindPort, betaBindPort, dohPort, dotPort, dnscryptTCPPort tcpPort,
</s> add bindPort, dohPort, dotPort, dnscryptTCPPort tcpPort, </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(opts.bindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(opts.bindPort)) </s> remove clientFS fs.FS
clientBetaFS fs.FS
</s> add clientFS fs.FS </s> remove CLIENT_BETA_DIR = client2
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/tls.go |
|
clientFS fs.FS | <mask> writeTimeout = 60 * time.Second
<mask> )
<mask>
<mask> type webConfig struct {
<mask> clientFS fs.FS
<mask> clientBetaFS fs.FS
<mask>
<mask> BindHost netip.Addr
<mask> BindPort int
<mask> BetaBindPort int
<mask> PortHTTPS int
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
BindHost netip.Addr
BindPort int
PortHTTPS int | <mask> type webConfig struct {
<mask> clientFS fs.FS
<mask> clientBetaFS fs.FS
<mask>
<mask> BindHost netip.Addr
<mask> BindPort int
<mask> BetaBindPort int
<mask> PortHTTPS int
<mask>
<mask> // ReadTimeout is an option to pass to http.Server for setting an
<mask> // appropriate field.
<mask> ReadTimeout time.Duration
<mask>
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove clientFS fs.FS
clientBetaFS fs.FS
</s> add clientFS fs.FS </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
<mask>
<mask> // TODO(a.garipov): Refactor all these servers.
<mask> httpServer *http.Server
<mask>
<mask> // httpServerBeta is a server for new client.
<mask> httpServerBeta *http.Server
<mask>
<mask> // handlerBeta is the handler for new client.
<mask> handlerBeta http.Handler
<mask>
<mask> // installerBeta is the pre-install handler for new client.
<mask> installerBeta http.Handler
<mask>
<mask> // httpsServer is the server that handles HTTPS traffic. If it is not nil,
<mask> // [Web.http3Server] must also not be nil.
<mask> httpsServer httpsServer
<mask>
<mask> forceHTTPS bool
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
</s> add </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
|
<mask> conf: conf,
<mask> }
<mask>
<mask> clientFS := http.FileServer(http.FS(conf.clientFS))
<mask> betaClientFS := http.FileServer(http.FS(conf.clientBetaFS))
<mask>
<mask> // if not configured, redirect / to /install.html, otherwise redirect /install.html to /
<mask> Context.mux.Handle("/", withMiddlewares(clientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler))
<mask> w.handlerBeta = withMiddlewares(betaClientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler)
<mask>
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove w.handlerBeta = withMiddlewares(betaClientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler)
</s> add </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add </s> remove // This must be removed in API v1.
w.registerBetaInstallHandlers()
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
|
<mask> betaClientFS := http.FileServer(http.FS(conf.clientBetaFS))
<mask>
<mask> // if not configured, redirect / to /install.html, otherwise redirect /install.html to /
<mask> Context.mux.Handle("/", withMiddlewares(clientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler))
<mask> w.handlerBeta = withMiddlewares(betaClientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler)
<mask>
<mask> // add handlers for /install paths, we only need them when we're not configured yet
<mask> if conf.firstRun {
<mask> log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ")
<mask> Context.mux.Handle("/install.html", preInstallHandler(clientFS))
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove betaClientFS := http.FileServer(http.FS(conf.clientBetaFS))
</s> add </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add </s> remove // This must be removed in API v1.
w.registerBetaInstallHandlers()
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
|
<mask> // add handlers for /install paths, we only need them when we're not configured yet
<mask> if conf.firstRun {
<mask> log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ")
<mask> Context.mux.Handle("/install.html", preInstallHandler(clientFS))
<mask> w.installerBeta = preInstallHandler(betaClientFS)
<mask> w.registerInstallHandlers()
<mask> // This must be removed in API v1.
<mask> w.registerBetaInstallHandlers()
<mask> } else {
<mask> registerControlHandlers()
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove // This must be removed in API v1.
w.registerBetaInstallHandlers()
</s> add </s> remove w.handlerBeta = withMiddlewares(betaClientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler)
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove BetaBindPort: 0,
</s> add </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
|
<mask> log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ")
<mask> Context.mux.Handle("/install.html", preInstallHandler(clientFS))
<mask> w.installerBeta = preInstallHandler(betaClientFS)
<mask> w.registerInstallHandlers()
<mask> // This must be removed in API v1.
<mask> w.registerBetaInstallHandlers()
<mask> } else {
<mask> registerControlHandlers()
<mask> }
<mask>
<mask> w.httpsServer.cond = sync.NewCond(&w.httpsServer.condLock)
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add </s> remove w.handlerBeta = withMiddlewares(betaClientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler)
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove BetaBindPort: 0,
</s> add </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
|
<mask>
<mask> errs <- web.httpServer.ListenAndServe()
<mask> }()
<mask>
<mask> web.startBetaServer(hostStr)
<mask>
<mask> err := <-errs
<mask> if !errors.Is(err, http.ErrServerClosed) {
<mask> cleanupAlways()
<mask> log.Fatal(err)
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
|
<mask> // address, so go back to the start of the loop.
<mask> }
<mask> }
<mask>
<mask> // startBetaServer starts the beta HTTP server if necessary.
<mask> func (web *Web) startBetaServer(hostStr string) {
<mask> if web.conf.BetaBindPort == 0 {
<mask> return
<mask> }
<mask>
<mask> // Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
<mask> hdlr := h2c.NewHandler(
<mask> withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
<mask> &http2.Server{},
<mask> )
<mask>
<mask> web.httpServerBeta = &http.Server{
<mask> ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
<mask> Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
<mask> Handler: hdlr,
<mask> ReadTimeout: web.conf.ReadTimeout,
<mask> ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
<mask> WriteTimeout: web.conf.WriteTimeout,
<mask> }
<mask> go func() {
<mask> defer log.OnPanic("web: plain: beta")
<mask>
<mask> betaErr := web.httpServerBeta.ListenAndServe()
<mask> if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
<mask> log.Error("starting beta http server: %s", betaErr)
<mask> }
<mask> }()
<mask> }
<mask>
<mask> // Close gracefully shuts down the HTTP servers.
<mask> func (web *Web) Close(ctx context.Context) {
<mask> log.Info("stopping http server...")
<mask>
<mask> web.httpsServer.cond.L.Lock()
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) | [
"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",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
|
<mask>
<mask> shutdownSrv(ctx, web.httpsServer.server)
<mask> shutdownSrv3(web.httpsServer.server3)
<mask> shutdownSrv(ctx, web.httpServer)
<mask> shutdownSrv(ctx, web.httpServerBeta)
<mask>
<mask> log.Info("stopped http server")
<mask> }
<mask>
<mask> func (web *Web) tlsServerLoop() {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | internal/home/web.go |
|
//go:embed build | <mask> // Embed the prebuilt client here since we strive to keep .go files inside the
<mask> // internal directory and the embed package is unable to embed files located
<mask> // outside of the same or underlying directory.
<mask>
<mask> //go:embed build build2
<mask> var clientBuildFS embed.FS
<mask>
<mask> func main() {
<mask> home.Main(clientBuildFS)
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove //go:embed build2
</s> add //go:embed build </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52 | main.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.