Commit 4e0f4111 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Update irma session command

parent 44d91d6c
...@@ -15,7 +15,7 @@ import ( ...@@ -15,7 +15,7 @@ import (
"github.com/privacybydesign/irmago" "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs" "github.com/privacybydesign/irmago/internal/fs"
"github.com/privacybydesign/irmago/server" "github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/irmarequestor" "github.com/privacybydesign/irmago/server/irmaserver"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
...@@ -23,7 +23,8 @@ import ( ...@@ -23,7 +23,8 @@ import (
const pollInterval = 1000 * time.Millisecond const pollInterval = 1000 * time.Millisecond
var ( var (
irmaServer *http.Server httpServer *http.Server
irmaServer *irmaserver.Server
logger *logrus.Logger logger *logrus.Logger
) )
...@@ -63,8 +64,8 @@ irma session --server http://localhost:48680 --authmethod token --key mytoken -- ...@@ -63,8 +64,8 @@ irma session --server http://localhost:48680 --authmethod token --key mytoken --
printSessionResult(result) printSessionResult(result)
// Done! // Done!
if irmaServer != nil { if httpServer != nil {
_ = irmaServer.Close() _ = httpServer.Close()
} }
}, },
} }
...@@ -83,7 +84,7 @@ func libraryRequest( ...@@ -83,7 +84,7 @@ func libraryRequest(
// Start the session // Start the session
resultchan := make(chan *server.SessionResult) resultchan := make(chan *server.SessionResult)
qr, _, err := irmarequestor.StartSession(request, func(r *server.SessionResult) { qr, _, err := irmaServer.StartSession(request, func(r *server.SessionResult) {
resultchan <- r resultchan <- r
}) })
if err != nil { if err != nil {
...@@ -209,7 +210,8 @@ func configureServer(port int, privatekeysPath string, irmaconfig *irma.Configur ...@@ -209,7 +210,8 @@ func configureServer(port int, privatekeysPath string, irmaconfig *irma.Configur
config.IssuerPrivateKeysPath = privatekeysPath config.IssuerPrivateKeysPath = privatekeysPath
} }
return irmarequestor.Initialize(config) irmaServer, err = irmaserver.New(config)
return err
} }
func configure(cmd *cobra.Command) (irma.RequestorRequest, *irma.Configuration, error) { func configure(cmd *cobra.Command) (irma.RequestorRequest, *irma.Configuration, error) {
...@@ -406,10 +408,10 @@ func parseDisjunctions(disjunctionsStr []string, conf *irma.Configuration) (irma ...@@ -406,10 +408,10 @@ func parseDisjunctions(disjunctionsStr []string, conf *irma.Configuration) (irma
func startServer(port int) { func startServer(port int) {
mux := http.NewServeMux() mux := http.NewServeMux()
mux.HandleFunc("/", irmarequestor.HttpHandlerFunc()) mux.HandleFunc("/", irmaServer.HttpHandlerFunc())
irmaServer = &http.Server{Addr: ":" + strconv.Itoa(port), Handler: mux} httpServer = &http.Server{Addr: ":" + strconv.Itoa(port), Handler: mux}
go func() { go func() {
err := irmaServer.ListenAndServe() err := httpServer.ListenAndServe()
if err != nil && err != http.ErrServerClosed { if err != nil && err != http.ErrServerClosed {
die("Failed to start server", err) die("Failed to start server", err)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment