<commit_before>package main

import (
	"context"
	"crypto/rsa"
	"crypto/tls"
	"crypto/x509"
	"encoding/asn1"
	"encoding/json"
	"encoding/pem"
	"flag"
	"fmt"
	"io"
	"io/ioutil"
	stdlog "log"
	"net/http"
	"net/http/httputil"
	"net/url"
	"os"
	"os/signal"
	"path/filepath"
	"strings"
	"syscall"
	"time"

	"golang.org/x/crypto/acme/autocert"
	"golang.org/x/crypto/pkcs12"

	"github.com/RobotsAndPencils/buford/push"
	"github.com/boltdb/bolt"
	"github.com/go-kit/kit/endpoint"
	"github.com/go-kit/kit/log"
	httptransport "github.com/go-kit/kit/transport/http"
	"github.com/gorilla/mux"
	"github.com/pkg/errors"

	"github.com/micromdm/dep"
	boltdepot "github.com/micromdm/scep/depot/bolt"
	scep "github.com/micromdm/scep/server"

	"github.com/micromdm/micromdm/checkin"
	"github.com/micromdm/micromdm/command"
	"github.com/micromdm/micromdm/connect"
	"github.com/micromdm/micromdm/depsync"
	"github.com/micromdm/micromdm/device"
	"github.com/micromdm/micromdm/enroll"
	"github.com/micromdm/micromdm/pubsub"
	nanopush "github.com/micromdm/micromdm/push"
)

const configDBPath = "/var/db/micromdm"

func serve(args []string) error {
	flagset := flag.NewFlagSet("serve", flag.ExitOnError)
	var (
		flServerURL    = flagset.String("server-url", "", "public HTTPS url of your server")
		flAPNSCertPath = flagset.String("apns-cert", "mdm.p12", "path to APNS certificate")
		flAPNSKeyPass  = flagset.String("apns-password", "secret", "password for your p12 APNS cert file (if using)")
		flAPNSKeyPath  = flagset.String("apns-key", "", "path to key file if using .pem push cert")
		flTLS          = flagset.Bool("tls", true, "use https")
		flTLSCert      = flagset.String("tls-cert", "", "path to TLS certificate")
		flTLSKey       = flagset.String("tls-key", "", "path to TLS private key")
		flHTTPAddr     = flagset.String("http-addr", ":https", "http(s) listen address of mdm server. defaults to :8080 if tls is false")
		flRedirAddr    = flagset.String("redir-addr", ":http", "http redirect to https listen address")
		flHTTPDebug    = flagset.Bool("http-debug", false, "enable debug for http(dumps full request)")
		flRepoPath     = flagset.String("filerepo", "", "path to http file repo")
		flDepSim       = flagset.Bool("depsim", false, "use depsim config")
	)
	flagset.Usage = usageFor(flagset, "micromdm serve [flags]")
	if err := flagset.Parse(args); err != nil {
		return err
	}

	logger := log.NewLogfmtLogger(os.Stderr)
	stdlog.SetOutput(log.NewStdlibAdapter(logger)) // force structured logs
	mainLogger := log.With(logger, "component", "main")
	mainLogger.Log("msg", "started")

	sm := &config{
		ServerPublicURL:     *flServerURL,<commit_msg>Enforce supplying -server-url (#79)<commit_after>package main

import (
	"context"
	"crypto/rsa"
	"crypto/tls"
	"crypto/x509"
	"encoding/asn1"
	"encoding/json"
	"encoding/pem"
	"flag"
	"fmt"
	"io"
	"io/ioutil"
	stdlog "log"
	"net/http"
	"net/http/httputil"
	"net/url"
	"os"
	"os/signal"
	"path/filepath"
	"strings"
	"syscall"
	"time"

	"golang.org/x/crypto/acme/autocert"
	"golang.org/x/crypto/pkcs12"

	"github.com/RobotsAndPencils/buford/push"
	"github.com/boltdb/bolt"
	"github.com/go-kit/kit/endpoint"
	"github.com/go-kit/kit/log"
	httptransport "github.com/go-kit/kit/transport/http"
	"github.com/gorilla/mux"
	"github.com/pkg/errors"

	"github.com/micromdm/dep"
	boltdepot "github.com/micromdm/scep/depot/bolt"
	scep "github.com/micromdm/scep/server"

	"github.com/micromdm/micromdm/checkin"
	"github.com/micromdm/micromdm/command"
	"github.com/micromdm/micromdm/connect"
	"github.com/micromdm/micromdm/depsync"
	"github.com/micromdm/micromdm/device"
	"github.com/micromdm/micromdm/enroll"
	"github.com/micromdm/micromdm/pubsub"
	nanopush "github.com/micromdm/micromdm/push"
)

const configDBPath = "/var/db/micromdm"

func serve(args []string) error {
	flagset := flag.NewFlagSet("serve", flag.ExitOnError)
	var (
		flServerURL    = flagset.String("server-url", "", "public HTTPS url of your server")
		flAPNSCertPath = flagset.String("apns-cert", "mdm.p12", "path to APNS certificate")
		flAPNSKeyPass  = flagset.String("apns-password", "<PASSWORD>", "password for your p12 APNS cert file (if using)")
		flAPNSKeyPath  = flagset.String("apns-key", "", "path to key file if using .pem push cert")
		flTLS          = flagset.Bool("tls", true, "use https")
		flTLSCert      = flagset.String("tls-cert", "", "path to TLS certificate")
		flTLSKey       = flagset.String("tls-key", "", "path to TLS private key")
		flHTTPAddr     = flagset.String("http-addr", ":https", "http(s) listen address of mdm server. defaults to :8080 if tls is false")
		flRedirAddr    = flagset.String("redir-addr", ":http", "http redirect to https listen address")
		flHTTPDebug    = flagset.Bool("http-debug", false, "enable debug for http(dumps full request)")
		flRepoPath     = flagset.String("filerepo", "", "path to http file repo")
		flDepSim       = flagset.Bool("depsim", false, "use depsim config")
	)
	flagset.Usage = usageFor(flagset, "micromdm serve [flags]")
	if err := flagset.Parse(args); err != nil {
		return err
	}

	if *flServerURL == "" {
		return errors.New("must supply -server-url")
	}

	logger := log.NewLogfmtLogger(os.Stderr)
	stdlog.SetOutput(log.NewStdlibAdapter(logger)) // force structured logs
	mainLogger := log.With(logger, "component", "main")
	mainLogger.Log("msg", "started")

	sm := &config{
		ServerPublicURL:     *flServerURL,
{'fraction_non_alphanumeric': 0.16048237476808905, 'fraction_numerical': 0.0055658627087198514, 'mean_word_length': 4.316568047337278, 'pattern_counts': {'":': 4, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2153281', 'n_tokens_mistral': 2165, 'n_tokens_neox': 2048, 'n_words': 390}