fix hostShort / hostLong bug
This commit is contained in:
		| @@ -34,20 +34,20 @@ const ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| type Muxer struct { | type Muxer struct { | ||||||
| 	muxer                                                            *mp4.Muxer | 	muxer                                                                       *mp4.Muxer | ||||||
| 	format                                                           string | 	format                                                                      string | ||||||
| 	limit                                                            int | 	limit                                                                       int | ||||||
| 	d                                                                *os.File | 	d                                                                           *os.File | ||||||
| 	m                                                                *os.File | 	m                                                                           *os.File | ||||||
| 	dur                                                              time.Duration | 	dur                                                                         time.Duration | ||||||
| 	h                                                                int | 	h                                                                           int | ||||||
| 	gof                                                              *Gof | 	gof                                                                         *Gof | ||||||
| 	patch                                                            string | 	patch                                                                       string | ||||||
| 	mpoint                                                           []string | 	mpoint                                                                      []string | ||||||
| 	start, end                                                       time.Time | 	start, end                                                                  time.Time | ||||||
| 	pstart, pend                                                     time.Duration | 	pstart, pend                                                                time.Duration | ||||||
| 	started                                                          bool | 	started                                                                     bool | ||||||
| 	serverID, streamName, channelName, streamID, channelID, hostname string | 	serverID, streamName, channelName, streamID, channelID, hostLong, hostShort string | ||||||
| } | } | ||||||
|  |  | ||||||
| type Gof struct { | type Gof struct { | ||||||
| @@ -76,7 +76,11 @@ func init() { | |||||||
| } | } | ||||||
|  |  | ||||||
| func NewMuxer(serverID, streamName, channelName, streamID, channelID string, mpoint []string, patch, format string, limit int) (m *Muxer, err error) { | func NewMuxer(serverID, streamName, channelName, streamID, channelID string, mpoint []string, patch, format string, limit int) (m *Muxer, err error) { | ||||||
| 	hostname, _ := os.Hostname() | 	hostLong, _ := os.Hostname() | ||||||
|  | 	var hostShort string | ||||||
|  | 	if p, _, ok := strings.Cut(hostLong, "."); ok { | ||||||
|  | 		hostShort = p | ||||||
|  | 	} | ||||||
| 	m = &Muxer{ | 	m = &Muxer{ | ||||||
| 		mpoint:      mpoint, | 		mpoint:      mpoint, | ||||||
| 		patch:       patch, | 		patch:       patch, | ||||||
| @@ -89,7 +93,8 @@ func NewMuxer(serverID, streamName, channelName, streamID, channelID string, mpo | |||||||
| 		channelName: channelName, | 		channelName: channelName, | ||||||
| 		streamID:    streamID, | 		streamID:    streamID, | ||||||
| 		channelID:   channelID, | 		channelID:   channelID, | ||||||
| 		hostname:    hostname, | 		hostLong:    hostLong, | ||||||
|  | 		hostShort:   hostShort, | ||||||
| 	} | 	} | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| @@ -253,11 +258,11 @@ func (m *Muxer) filePatch() (string, error) { | |||||||
| 		case "{server_id}": | 		case "{server_id}": | ||||||
| 			ts = strings.Replace(ts, "{server_id}", m.serverID, -1) | 			ts = strings.Replace(ts, "{server_id}", m.serverID, -1) | ||||||
| 		case "{host_name}": | 		case "{host_name}": | ||||||
| 			ts = strings.Replace(ts, "{host_name}", m.hostname, -1) | 			ts = strings.Replace(ts, "{host_name}", m.hostLong, -1) | ||||||
| 		case "{host_name_short}": | 		case "{host_name_short}": | ||||||
| 			ts = strings.Replace(ts, "{host_name_short}", m.hostname, -1) | 			ts = strings.Replace(ts, "{host_name_short}", m.hostShort, -1) | ||||||
| 		case "{host_name_long}": | 		case "{host_name_long}": | ||||||
| 			ts = strings.Replace(ts, "{host_name_long}", m.hostname, -1) | 			ts = strings.Replace(ts, "{host_name_long}", m.hostLong, -1) | ||||||
| 		case "{stream_name}": | 		case "{stream_name}": | ||||||
| 			ts = strings.Replace(ts, "{stream_name}", m.streamName, -1) | 			ts = strings.Replace(ts, "{stream_name}", m.streamName, -1) | ||||||
| 		case "{channel_name}": | 		case "{channel_name}": | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andrey Semochkin
					Andrey Semochkin