github.com/google/trillian-examples@v0.0.0-20240520080811-0d40d35cef0e/binary_transparency/firmware/cmd/ft_personality/ft_personality.go (about)

     1  // Copyright 2020 Google LLC. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // This package is the entrypoint for the Firmware Transparency personality server.
    16  // This requires a Trillian instance to be reachable via gRPC and a tree to have
    17  // been provisioned. See the README in the root of this project for instructions.
    18  package main
    19  
    20  import (
    21  	"context"
    22  	"flag"
    23  	"time"
    24  
    25  	"github.com/golang/glog"
    26  	"github.com/google/trillian-examples/binary_transparency/firmware/cmd/ft_personality/impl"
    27  	"github.com/google/trillian-examples/binary_transparency/firmware/internal/crypto"
    28  	"golang.org/x/mod/sumdb/note"
    29  )
    30  
    31  var (
    32  	listenAddr = flag.String("listen", ":8000", "address:port to listen for requests on")
    33  
    34  	connectTimeout = flag.Duration("connect_timeout", time.Second, "the timeout for connecting to the backend")
    35  	trillianAddr   = flag.String("trillian", ":8090", "address:port of Trillian Log gRPC service")
    36  
    37  	casDBFile = flag.String("cas_db_file", "", "Path to a file to be used as sqlite3 storage for images, e.g. /tmp/ft.db")
    38  
    39  	sthRefresh = flag.Duration("sth_refresh_interval", 5*time.Second, "how often to fetch the latest log root from Trillian")
    40  )
    41  
    42  func main() {
    43  	flag.Parse()
    44  
    45  	signer, err := note.NewSigner(crypto.TestFTPersonalityPriv)
    46  	if err != nil {
    47  		panic(err)
    48  	}
    49  
    50  	ctx := context.Background()
    51  	if err := impl.Main(ctx, impl.PersonalityOpts{
    52  		ListenAddr:     *listenAddr,
    53  		ConnectTimeout: *connectTimeout,
    54  		TrillianAddr:   *trillianAddr,
    55  		CASFile:        *casDBFile,
    56  		STHRefresh:     *sthRefresh,
    57  		Signer:         signer,
    58  	}); err != nil {
    59  		glog.Exitf("Error running personality: %q", err)
    60  	}
    61  }