import { SimpleLocalClient } from '../../core/index.js';
import type { IIperf3Config, IIperf3Snapshot } from './iperf3.types.js';
import { iperf3Profile } from './iperf3.types.js';

export class Iperf3Client extends SimpleLocalClient<IIperf3Config> {
  constructor(private readonly configArg: IIperf3Config) {
    super(iperf3Profile, configArg);
  }

  public async getSnapshot(forceRefreshArg = false): Promise<IIperf3Snapshot> {
    return new SimpleLocalClient<IIperf3Config>(iperf3Profile, safeSnapshotConfig(this.configArg)).getSnapshot(forceRefreshArg) as Promise<IIperf3Snapshot>;
  }
}

const safeSnapshotConfig = (configArg: IIperf3Config): IIperf3Config => {
  const { host, port, path, transport, tcpCommand, useTls, url, ...safeConfig } = configArg;
  void host;
  void port;
  void path;
  void transport;
  void tcpCommand;
  void useTls;
  void url;
  return safeConfig;
};
