// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package tcp

import (
	
	
	
	
	
)

type ipv6ZoneCache struct {
	sync.RWMutex
	lastFetched time.Time
	toIndex     map[string]int
	toName      map[int]string
}

var zoneCache = ipv6ZoneCache{
	toIndex: make(map[string]int),
	toName:  make(map[int]string),
}

func ( *ipv6ZoneCache) ( string) int {
	if  == "" {
		return 0
	}
	.update()
	.RLock()
	defer .RUnlock()
	,  := .toIndex[]
	if ! {
		, _ = strconv.Atoi()
	}
	return 
}

func ( *ipv6ZoneCache) ( int) string {
	if  == 0 {
		return ""
	}
	.update()
	.RLock()
	defer .RUnlock()
	,  := .toName[]
	if ! {
		 = fmt.Sprintf("%d", )
	}
	return 
}

func ( *ipv6ZoneCache) () {
	.Lock()
	defer .Unlock()
	 := time.Now()
	if .lastFetched.After(.Add(-60 * time.Second)) {
		return
	}
	.lastFetched = 
	,  := net.Interfaces()
	if  != nil {
		return
	}
	.toIndex = make(map[string]int, len())
	.toName = make(map[int]string, len())
	for ,  := range  {
		.toIndex[.Name] = .Index
		.toName[.Index] = .Name
	}
}