You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: service.go
    path of file: ./repos/syncthing/lib/nat
    
    the code of the file until where you have to start completion: // Copyright (C) 2015 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

package nat

import (
	"context"
	"fmt"
	"hash/fnv"
	"math/rand"
	"net"
	"slices"
	stdsync "sync"
	"time"

	"github.com/syncthing/syncthing/lib/config"
	"github.com/syncthing/syncthing/lib/protocol"
	"github.com/syncthing/syncthing/lib/sync"
)

// Service runs a loop for discovery of IGDs (Internet Gateway Devices) and
// setup/renewal of a port mapping.
type Service struct {
	id               protocol.DeviceID
	cfg              config.Wrapper
	processScheduled chan struct{}

	mappings []*Mapping
	enabled  bool
	mut      sync.RWMutex
}

func NewService(id protocol.DeviceID, cfg config.Wrapper) *Service {
	s := &Service{
		id:               id,
		cfg:           
    
func (s *Service) acquireNewLocked(ctx context.Context, mapping *Mapping, nats map[string]Device) (change bool) {
	leaseTime := time.Duration(s.cfg.Options().NATLeaseM) * time.Minute
	addrMap := mapping.extAddresses

	for id, nat := range nats {
		select {
		case <-ctx.Done():
			return false
		default:
		}

		if _, ok := addrMap[id]; ok {
			continue
		}

		// Only perform mappings on the nat's that have the right local IP
		// address
		localIP := nat.GetLocalIPv4Address()
		if !mapping.validGateway(localIP) && nat.SupportsIPVersion(IPv4Only) {
			l.Debugf("Skipping %s for %s because of IP mismatch. %s != %s", id, mapping, mapping.address.IP, localIP)
			continue
		}

		l.Debugf("Trying to open port %s on %s", mapping, id)

		if !nat.SupportsIPVersion(mapping.ipVersion) {
			l.Debugf("Skipping firewall traversal on gateway %s because it doesn't match the listener address family", nat.ID())
			continue
		}

		addrs, err := s.tryNATDevice(ctx, nat, mapping.address, 0, leaseTime)
		if err != nil {
			l.Debugf("Failed to acquire %s open port on %s", mapping, id)
			continue
		}

		l.Debugf("Opened port %s -> %v on %s", mapping, addrs, id)
		mapping.setAddressLocked(id, addrs)
		change = true
	}

	return change
}