* docs: add user guide, faq, and enhance troubleshooting - Created docs/user-guide.md with key concepts and workflows. - Created docs/faq.md with common questions and answers. - Enhanced docs/troubleshooting.md with AI/Agentic issues. - Updated README.md with CLI Quick Start and Getting Help sections. - Refactored mkdocs.yml to reflect actual file structure and include new docs. * docs: add user documentation and fix mkdocs navigation - Created docs/user-guide.md and docs/faq.md. - Enhanced docs/troubleshooting.md with AI/Agentic issues. - Updated README.md with CLI Quick Start and Help links. - Restored original mkdocs.yml navigation and added new user documentation sections. - Fixed formatting in pkg/io/local/client.go to ensure CI passes. * docs: add user documentation and fix auto-merge workflow - Created docs/user-guide.md and docs/faq.md with user-focused content. - Enhanced docs/troubleshooting.md with AI/Agentic issue solutions. - Updated README.md with CLI Quick Start and organized help links. - Refactored mkdocs.yml to include new documentation while preserving technical sections. - Fixed .github/workflows/auto-merge.yml by inlining the logic and adding git repository context (checkout and -R flag) to resolve CI failures. - Verified that docs/workflows.md is present in the repository. * docs: add user documentation and resolve merge conflict - Created docs/user-guide.md and docs/faq.md. - Enhanced docs/troubleshooting.md with AI/Agentic issue solutions. - Updated README.md with CLI Quick Start and Help sections. - Merged latest base branch changes and resolved conflict in .github/workflows/auto-merge.yml. - Verified and organized mkdocs.yml navigation. * docs: add user documentation and fix UniFi security issue - Created docs/user-guide.md and docs/faq.md. - Enhanced docs/troubleshooting.md. - Updated README.md with CLI Quick Start. - Fixed UniFi security vulnerability (CodeQL alert) by making TLS verification configurable. - Added --insecure flag to UniFi CLI commands. - Verified all documentation links and navigation. * docs: add user documentation and fix formatting/security - Created docs/user-guide.md and docs/faq.md. - Enhanced docs/troubleshooting.md. - Updated README.md with CLI Quick Start. - Fixed UniFi security vulnerability by making TLS verification configurable. - Added --insecure flag to UniFi CLI commands. - Fixed formatting in internal/cmd/unifi/cmd_config.go. - Verified all documentation links and navigation. --------- Co-authored-by: Claude <developers@lethean.io>
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package unifi
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"net/http"
|
|
|
|
uf "github.com/unpoller/unifi/v5"
|
|
|
|
"github.com/host-uk/core/pkg/log"
|
|
)
|
|
|
|
// Client wraps the unpoller UniFi client with config-based auth.
|
|
type Client struct {
|
|
api *uf.Unifi
|
|
url string
|
|
}
|
|
|
|
// New creates a new UniFi API client for the given controller URL and credentials.
|
|
// TLS verification can be disabled via the insecure parameter (useful for self-signed certs on home lab controllers).
|
|
func New(url, user, pass, apikey string, insecure bool) (*Client, error) {
|
|
cfg := &uf.Config{
|
|
URL: url,
|
|
User: user,
|
|
Pass: pass,
|
|
APIKey: apikey,
|
|
}
|
|
|
|
// Skip TLS verification if requested (e.g. for self-signed certs)
|
|
httpClient := &http.Client{
|
|
Transport: &http.Transport{
|
|
TLSClientConfig: &tls.Config{
|
|
InsecureSkipVerify: insecure,
|
|
MinVersion: tls.VersionTLS12,
|
|
},
|
|
},
|
|
}
|
|
|
|
api, err := uf.NewUnifi(cfg)
|
|
if err != nil {
|
|
return nil, log.E("unifi.New", "failed to create client", err)
|
|
}
|
|
|
|
// Override the HTTP client to skip TLS verification
|
|
api.Client = httpClient
|
|
|
|
return &Client{api: api, url: url}, nil
|
|
}
|
|
|
|
// API exposes the underlying SDK client for direct access.
|
|
func (c *Client) API() *uf.Unifi { return c.api }
|
|
|
|
// URL returns the UniFi controller URL.
|
|
func (c *Client) URL() string { return c.url }
|